Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Feb 2009 03:32:24 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r188368 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp
Message-ID:  <200902090332.n193WOPc043706@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Mon Feb  9 03:32:23 2009
New Revision: 188368
URL: http://svn.freebsd.org/changeset/base/188368

Log:
  MFC r185273
    Fix Tx/Rx checksum offload ioctl handling and make Rx handler honor
    checksum offload configuration. Now checksum offload can be
    controlled by ifconfig(8).
    While I'm here add an additional check for interface capabilities
    before applying user's request.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/dev/fxp/if_fxp.c

Modified: stable/7/sys/dev/fxp/if_fxp.c
==============================================================================
--- stable/7/sys/dev/fxp/if_fxp.c	Mon Feb  9 03:31:53 2009	(r188367)
+++ stable/7/sys/dev/fxp/if_fxp.c	Mon Feb  9 03:32:23 2009	(r188368)
@@ -1558,6 +1558,7 @@ fxp_intr_body(struct fxp_softc *sc, stru
 	struct fxp_rfa *rfa;
 	int rnr = (statack & FXP_SCB_STATACK_RNR) ? 1 : 0;
 	int fxp_rc = 0;
+	uint16_t status;
 
 	FXP_LOCK_ASSERT(sc, MA_OWNED);
 	if (rnr)
@@ -1635,7 +1636,8 @@ fxp_intr_body(struct fxp_softc *sc, stru
 		}
 #endif /* DEVICE_POLLING */
 
-		if ((le16toh(rfa->rfa_status) & FXP_RFA_STATUS_C) == 0)
+		status = le16toh(rfa->rfa_status);
+		if ((status & FXP_RFA_STATUS_C) == 0)
 			break;
 
 		/*
@@ -1661,14 +1663,14 @@ fxp_intr_body(struct fxp_softc *sc, stru
 			total_len = le16toh(rfa->actual_size) & 0x3fff;
 			if (total_len < sizeof(struct ether_header) ||
 			    total_len > MCLBYTES - RFA_ALIGNMENT_FUDGE -
-				sc->rfa_size ||
-			    le16toh(rfa->rfa_status) & FXP_RFA_STATUS_CRC) {
+				sc->rfa_size || status & FXP_RFA_STATUS_CRC) {
 				m_freem(m);
 				continue;
 			}
 
                         /* Do IP checksum checking. */
-			if (le16toh(rfa->rfa_status) & FXP_RFA_STATUS_PARSE) {
+			if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 &&
+			    (status & FXP_RFA_STATUS_PARSE)) {
 				if (rfa->rfax_csum_sts &
 				    FXP_RFDX_CS_IP_CSUM_BIT_VALID)
 					m->m_pkthdr.csum_flags |=
@@ -2372,7 +2374,7 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 	struct fxp_softc *sc = ifp->if_softc;
 	struct ifreq *ifr = (struct ifreq *)data;
 	struct mii_data *mii;
-	int flag, mask, error = 0;
+	int flag, mask, error = 0, reinit;
 
 	switch (command) {
 	case SIOCSIFFLAGS:
@@ -2432,6 +2434,7 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 		break;
 
 	case SIOCSIFCAP:
+		reinit = 0;
 		mask = ifp->if_capenable ^ ifr->ifr_reqcap;
 #ifdef DEVICE_POLLING
 		if (mask & IFCAP_POLLING) {
@@ -2454,8 +2457,20 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 			}
 		}
 #endif
-		if (mask & IFCAP_VLAN_MTU) {
-			FXP_LOCK(sc);
+		FXP_LOCK(sc);
+		if ((mask & IFCAP_TXCSUM) != 0 &&
+		    (ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
+			ifp->if_capenable ^= IFCAP_TXCSUM;
+			if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
+				ifp->if_hwassist |= FXP_CSUM_FEATURES;
+			else
+				ifp->if_hwassist &= ~FXP_CSUM_FEATURES;
+		}
+		if ((mask & IFCAP_RXCSUM) != 0 &&
+		    (ifp->if_capabilities & IFCAP_RXCSUM) != 0)
+			ifp->if_capenable ^= IFCAP_RXCSUM;
+		if ((mask & IFCAP_VLAN_MTU) != 0 &&
+		    (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) {
 			ifp->if_capenable ^= IFCAP_VLAN_MTU;
 			if (sc->revision != FXP_REV_82557)
 				flag = FXP_FLAG_LONG_PKT_EN;
@@ -2463,9 +2478,11 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
 				flag = FXP_FLAG_SAVE_BAD;
 			sc->flags ^= flag;
 			if (ifp->if_flags & IFF_UP)
-				fxp_init_body(sc);
-			FXP_UNLOCK(sc);
+				reinit++;
 		}
+		if (reinit > 0)
+			fxp_init_body(sc);
+		FXP_UNLOCK(sc);
 		break;
 
 	default:



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