PERFORCE change 131915 for review

Hans Petter Selasky hselasky at FreeBSD.org
Fri Dec 28 14:01:26 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=131915

Change 131915 by hselasky at hselasky_laptop001 on 2007/12/28 22:00:38

	
	Style change by "usb_style.sh" and some manual editing.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#41 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/if_cdce.c#41 (text+ko) ====

@@ -340,21 +340,25 @@
 
 	/*
 	 * <quote>
-	 *  The Data Class interface of a networking device shall have a minimum
-	 *  of two interface settings. The first setting (the default interface
-	 *  setting) includes no endpoints and therefore no networking traffic is
-	 *  exchanged whenever the default interface setting is selected. One or
-	 *  more additional interface settings are used for normal operation, and
-	 *  therefore each includes a pair of endpoints (one IN, and one OUT) to
-	 *  exchange network traffic. Select an alternate interface setting to
-	 *  initialize the network aspects of the device and to enable the
-	 *  exchange of network traffic.
+	 *
+	 *  The Data Class interface of a networking device shall have
+	 *  a minimum of two interface settings. The first setting
+	 *  (the default interface setting) includes no endpoints and
+	 *  therefore no networking traffic is exchanged whenever the
+	 *  default interface setting is selected. One or more
+	 *  additional interface settings are used for normal
+	 *  operation, and therefore each includes a pair of endpoints
+	 *  (one IN, and one OUT) to exchange network traffic. Select
+	 *  an alternate interface setting to initialize the network
+	 *  aspects of the device and to enable the exchange of
+	 *  network traffic.
+	 *
 	 * </quote>
 	 *
-	 * Some devices, most notably cable modems, include interface settings
-	 * that have no IN or OUT endpoint, therefore loop through the list of all
-	 * available interface settings looking for one with both IN and OUT
-	 * endpoints.
+	 * Some devices, most notably cable modems, include interface
+	 * settings that have no IN or OUT endpoint, therefore loop
+	 * through the list of all available interface settings
+	 * looking for one with both IN and OUT endpoints.
 	 */
 
 alloc_transfers:
@@ -581,7 +585,7 @@
 	switch (USBD_GET_STATE(xfer)) {
 	case USBD_ST_TRANSFERRED:
 		DPRINTF(sc, 10, "transfer complete: "
-		    "%u bytes in %u frames\n", xfer->actlen, 
+		    "%u bytes in %u frames\n", xfer->actlen,
 		    xfer->aframes);
 
 		ifp->if_opackets++;
@@ -593,99 +597,99 @@
 			usbd_transfer_start(sc->sc_xfer[2]);
 			goto done;
 		}
-
 #ifdef CDCE_MF_ENABLE
-			x = 1;
+		x = 1;
 #else
-			x = 0;
+		x = 0;
 #endif
 		while (x != CDCE_ETH_FRAMES_MAX) {
 
-		IFQ_DRV_DEQUEUE(&(ifp->if_snd), m);
+			IFQ_DRV_DEQUEUE(&(ifp->if_snd), m);
 
-		if (m == NULL) {
+			if (m == NULL) {
 #ifdef CDCE_DO_BENCHMARK
-			/* send dummy ethernet frames */
-			usbd_set_frame_data(xfer, &(sc->sc_rx_dump), x);
-			xfer->frlengths[x] = (sizeof(sc->sc_rx_dump) / 2) + 
-			  (x & 63) - 1;
-			x++;
-			continue;
+				/* send dummy ethernet frames */
+				usbd_set_frame_data(xfer,
+				    &(sc->sc_rx_dump), x);
+				xfer->frlengths[x] =
+				    (sizeof(sc->sc_rx_dump) / 2) + (x & 63) - 1;
+				x++;
+				continue;
 #else
-			break;
+				break;
 #endif
-		}
+			}
+			if (m->m_pkthdr.len < sizeof(struct ether_header)) {
+				/*
+				 * frames of this size have special meaning
+				 * - filter away
+				 */
+				m_freem(m);
+				ifp->if_oerrors++;
+				continue;
+			}
+			if (sc->sc_flags & CDCE_FLAG_ZAURUS) {
+				/*
+				 * Zaurus wants a 32-bit CRC appended to
+				 * every frame
+				 */
 
-		if (m->m_pkthdr.len < sizeof(struct ether_header)) {
-		  /* frames of this size have special meaning - filter away */
-		  m_freem(m);
-		  ifp->if_oerrors++;
-		  continue;
-		}
+				crc = cdce_m_crc32(m, 0, m->m_pkthdr.len);
+				crc = htole32(crc);
 
-		if (sc->sc_flags & CDCE_FLAG_ZAURUS) {
-			/* Zaurus wants a 32-bit CRC appended to every frame */
-
-			crc = cdce_m_crc32(m, 0, m->m_pkthdr.len);
-			crc = htole32(crc);
-
-			if (!m_append(m, 4, (void *)&crc)) {
-			  m_freem(m);
-			  ifp->if_oerrors++;
-			  continue;
+				if (!m_append(m, 4, (void *)&crc)) {
+					m_freem(m);
+					ifp->if_oerrors++;
+					continue;
+				}
+				m->m_pkthdr.len += 4;
+			}
+			if (m->m_pkthdr.len > MCLBYTES) {
+				m->m_pkthdr.len = MCLBYTES;
+			}
+			m = m_pullup(m, m->m_pkthdr.len);
+			if (m == NULL) {
+				ifp->if_oerrors++;
+				continue;
 			}
+			sc->sc_tx_mbufs[x] = m;
 
-			m->m_pkthdr.len += 4;
-		}
+			xfer->frlengths[x] = m->m_len;
 
-		if (m->m_pkthdr.len > MCLBYTES) {
-			m->m_pkthdr.len = MCLBYTES;
-		}
+			usbd_set_frame_data(xfer, m->m_data, x);
 
-		m = m_pullup(m, m->m_pkthdr.len);
-		if (m == NULL) {
-		ifp->if_oerrors++;
-		continue;
-		}
+			/*
+			 * if there's a BPF listener, bounce a copy
+			 * of this frame to him:
+			 */
+			BPF_MTAP(ifp, m);
 
-		sc->sc_tx_mbufs[x] = m;
-
-		xfer->frlengths[x] = m->m_len;
-
-		usbd_set_frame_data(xfer, m->m_data, x);
-
-		/*
-		 * if there's a BPF listener, bounce a copy
-		 * of this frame to him:
-		 */
-		BPF_MTAP(ifp, m);
-
-		x++;
+			x++;
 		}
 
 		xfer->nframes = x;
 
 #ifdef CDCE_MF_ENABLE
-		  if (x == 1) {
-		    /* nothing to do */
-		    goto done;
-		  }
-		  /* fill out the Multi Frame header */
-		  usbd_set_frame_data(xfer, &(sc->sc_tx_eth.hdr), 0);
-		  xfer->frlengths[0] = sizeof(sc->sc_tx_eth.hdr);
-		  sc->sc_tx_eth.hdr.bSig0[0] = 'M';
-		  sc->sc_tx_eth.hdr.bSig0[1] = 'F';
-		  x--;
-		  /* tell the peer how many frames are coming */
-		  x += ifp->if_snd.ifq_drv_len;
-		  USETDW(sc->sc_tx_eth.hdr.dwFramesAhead, x);
-		  x = ~x;
-		  USETDW(sc->sc_tx_eth.hdr.dwFramesAheadInverse, x);
+		if (x == 1) {
+			/* nothing to do */
+			goto done;
+		}
+		/* fill out the Multi Frame header */
+		usbd_set_frame_data(xfer, &(sc->sc_tx_eth.hdr), 0);
+		xfer->frlengths[0] = sizeof(sc->sc_tx_eth.hdr);
+		sc->sc_tx_eth.hdr.bSig0[0] = 'M';
+		sc->sc_tx_eth.hdr.bSig0[1] = 'F';
+		x--;
+		/* tell the peer how many frames are coming */
+		x += ifp->if_snd.ifq_drv_len;
+		USETDW(sc->sc_tx_eth.hdr.dwFramesAhead, x);
+		x = ~x;
+		USETDW(sc->sc_tx_eth.hdr.dwFramesAheadInverse, x);
 #else
-		  if (x == 0) {
-		    /* nothing to do */
-		    goto done;
-		  }
+		if (x == 0) {
+			/* nothing to do */
+			goto done;
+		}
 #endif
 
 		usbd_start_hardware(xfer);
@@ -792,7 +796,8 @@
 
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
-		error = ifmedia_ioctl(ifp, (void *)data, &sc->sc_ifmedia, command);
+		error = ifmedia_ioctl(ifp, (void *)data,
+		    &sc->sc_ifmedia, command);
 		break;
 
 	default:
@@ -851,7 +856,7 @@
 static void
 cdce_bulk_read_callback(struct usbd_xfer *xfer)
 {
-	struct cdce_mq mq = { NULL, NULL, 0 };
+	struct cdce_mq mq = {NULL, NULL, 0};
 	struct cdce_softc *sc = xfer->priv_sc;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct mbuf *m;
@@ -864,67 +869,76 @@
 	case USBD_ST_TRANSFERRED:
 
 		DPRINTF(sc, 0, "received %u bytes in %u frames\n",
-			xfer->actlen, xfer->aframes);
+		    xfer->actlen, xfer->aframes);
 
 		for (x = 0; x != xfer->nframes; x++) {
 
-		if (sc->sc_flags & CDCE_FLAG_ZAURUS) {
+			if (sc->sc_flags & CDCE_FLAG_ZAURUS) {
 
-			/* Strip off CRC added by Zaurus */
-			if (xfer->frlengths[x] >= MAX(4,14)) {
-				xfer->frlengths[x] -= 4;
+				/* Strip off CRC added by Zaurus */
+				if (xfer->frlengths[x] >= MAX(4, 14)) {
+					xfer->frlengths[x] -= 4;
+				}
+			}
+			m = sc->sc_rx_mbufs[x];
+			sc->sc_rx_mbufs[x] = NULL;
+			if (m == NULL) {
+				continue;
 			}
-		}
-
-		m = sc->sc_rx_mbufs[x];
-		sc->sc_rx_mbufs[x] = NULL;
-		if (m == NULL) {
-			continue;
-		}
+			if (xfer->frlengths[x] < sizeof(struct ether_header)) {
 
-		if (xfer->frlengths[x] < sizeof(struct ether_header)) {
-
 #ifdef CDCE_MF_ENABLE
-			if (xfer->frlengths[x] >= CDC_MF_ETH_HEADER_SIZE) {
+				if (xfer->frlengths[x] >=
+				    CDC_MF_ETH_HEADER_SIZE) {
 
-			mf_hdr = (void *)(m->m_data);
+					mf_hdr = (void *)(m->m_data);
 
-			/* decode and verify multi frame header */
+					/*
+					 * decode and verify the multi
+					 * frame header
+					 */
 
-			ta = UGETDW(mf_hdr->dwFramesAhead);
-			tb = UGETDW(mf_hdr->dwFramesAheadInverse);
-			tb ^= ta;
+					ta = UGETDW(mf_hdr->dwFramesAhead);
+					tb = UGETDW(mf_hdr->dwFramesAheadInverse);
+					tb ^= ta;
 
-		    DPRINTF(sc, 0, "ta = 0x%08x, tb = 0x%08x\n", ta, tb);
+					DPRINTF(sc, 0, "ta = 0x%08x, "
+					    "tb = 0x%08x\n", ta, tb);
 
-			/* check if we have a multi frame header */
-			if ((tb == 0xFFFFFFFF) &&
-			    (mf_hdr->bSig0[0] == 'M') &&
-			    (mf_hdr->bSig0[1] == 'F')) {
+					/*
+					 * check if we have a multi frame
+					 * header
+					 */
+					if ((tb == 0xFFFFFFFF) &&
+					    (mf_hdr->bSig0[0] == 'M') &&
+					    (mf_hdr->bSig0[1] == 'F')) {
 
-			    DPRINTF(sc, 0, "frames ahead "
-				    "= %u\n", ta);
+						DPRINTF(sc, 0, "frames ahead "
+						    "= %u\n", ta);
 
-			    sc->sc_rx_frames_ahead = ta;
-			}
-			}
+						sc->sc_rx_frames_ahead = ta;
+					}
+				}
 #endif
 
-			m_freem(m);
-			continue;
-		} else {
-		  /* we received a frame - decrement frames ahead */
-		  if (sc->sc_rx_frames_ahead) {
-		    sc->sc_rx_frames_ahead--;
-		  }
-		}
+				m_freem(m);
+				continue;
+			} else {
+				/*
+				 * we received a frame - decrement frames
+				 * ahead
+				 */
+				if (sc->sc_rx_frames_ahead) {
+					sc->sc_rx_frames_ahead--;
+				}
+			}
 
-		ifp->if_ipackets++;
-		m->m_pkthdr.rcvif = ifp;
-		m->m_pkthdr.len = m->m_len = xfer->frlengths[x];
+			ifp->if_ipackets++;
+			m->m_pkthdr.rcvif = ifp;
+			m->m_pkthdr.len = m->m_len = xfer->frlengths[x];
 
-		/* enqueue */
-		_IF_ENQUEUE(&(mq), m);
+			/* enqueue */
+			_IF_ENQUEUE(&(mq), m);
 		}
 
 	case USBD_ST_SETUP:
@@ -934,58 +948,54 @@
 			/* reset number of frames ahead */
 			sc->sc_rx_frames_ahead = 0;
 
-		  if (xfer->flags_int.usb_mode == USB_MODE_HOST) {
-			usbd_transfer_start(sc->sc_xfer[3]);
-			/* 
-			 * In case the "stall_pipe" flag was set
-			 * while transferring data, we need to go
-			 * to the "tr_if_input" afterwards!
-			 */
-			goto tr_if_input;
-		  }
-		} 
-
+			if (xfer->flags_int.usb_mode == USB_MODE_HOST) {
+				usbd_transfer_start(sc->sc_xfer[3]);
+				/*
+				 * In case the "stall_pipe" flag was set
+				 * while transferring data, we need to go to
+				 * the "tr_if_input" afterwards!
+				 */
+				goto tr_if_input;
+			}
+		}
 		/* setup a new USB transfer chain */
 
-		  ta = sc->sc_rx_frames_ahead;
+		ta = sc->sc_rx_frames_ahead;
 
-		  if (ta == 0) {
-		    /* always receive at least one frame */
-		    ta = 1;
-		  }
-
-		  if (ta > CDCE_ETH_FRAMES_MAX) {
-		      ta = CDCE_ETH_FRAMES_MAX;
-		  }
-
-		  for (x = 0; x != ta; x++) {
+		if (ta == 0) {
+			/* always receive at least one frame */
+			ta = 1;
+		}
+		if (ta > CDCE_ETH_FRAMES_MAX) {
+			ta = CDCE_ETH_FRAMES_MAX;
+		}
+		for (x = 0; x != ta; x++) {
 			m = usbd_ether_get_mbuf();
 			if (m == NULL) {
-			  break;
+				break;
 			}
-
 			usbd_set_frame_data(xfer, m->m_data, x);
 
 			xfer->frlengths[x] = m->m_len;
 			sc->sc_rx_mbufs[x] = m;
-		  }
+		}
 
-		  for ( ; x != ta; x++) {
+		for (; x != ta; x++) {
 
-			/* 
-			 * We are out of mbufs and need to dump all
-			 * the received data !
+			/*
+			 * We are out of mbufs and need to dump all the
+			 * received data !
 			 */
 			usbd_set_frame_data(xfer, &(sc->sc_rx_dump), x);
 			xfer->frlengths[x] = sizeof(sc->sc_rx_dump);
-		  }
-			xfer->nframes = ta;
-			usbd_start_hardware(xfer);
+		}
+		xfer->nframes = ta;
+		usbd_start_hardware(xfer);
 
 		/*
-		 * At the end of a USB callback it is always safe to unlock
-		 * the private mutex of a device! That is why we do the
-		 * "if_input" here, and not some lines up!
+		 * At the end of a USB callback it is always safe to
+		 * unlock the private mutex of a device! That is why
+		 * we do the "if_input" here, and not some lines up!
 		 *
 		 * By safe we mean that if "usbd_transfer_stop()" is
 		 * called, we will get a callback having the error


More information about the p4-projects mailing list