Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2015 13:21:24 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r277068 - in projects/ifnet/sys: dev/virtio/network net
Message-ID:  <201501121321.t0CDLO56007327@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Mon Jan 12 13:21:23 2015
New Revision: 277068
URL: https://svnweb.freebsd.org/changeset/base/277068

Log:
  More improvements/adjustments to interface flags/variables handling based
  on conversion of a couple of drivers:
  
  - Rename if_getflags() -> if_get(), if_setflags() -> if_set(). The function
    itself deal not only with flags, but with any integer values.
  - Reimplement flag manipulation macros as inlines.
  - Reimplement if_getsoftc() over if_getfeature().
  - Provide access to IF_INDEX, IF_FLAGS, IF_FIB, IF_LLADDR, IF_BPF,
    IF_NAME.
  - Provide typecasting inlines for if_name(), if_lladdr() working
    over if_getsoftc().
  - Remove if_capenable(), instead automatically callbacks upon
    modifications of certain values in if_set_special().
  
  Sponsored by:	Nginx, Inc.

Modified:
  projects/ifnet/sys/dev/virtio/network/if_vtnet.c
  projects/ifnet/sys/net/if.c
  projects/ifnet/sys/net/if.h
  projects/ifnet/sys/net/if_loop.c
  projects/ifnet/sys/net/if_var.h

Modified: projects/ifnet/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- projects/ifnet/sys/dev/virtio/network/if_vtnet.c	Mon Jan 12 13:14:37 2015	(r277067)
+++ projects/ifnet/sys/dev/virtio/network/if_vtnet.c	Mon Jan 12 13:21:23 2015	(r277068)
@@ -481,7 +481,7 @@ vtnet_resume(device_t dev)
 	ifp = sc->vtnet_ifp;
 
 	VTNET_CORE_LOCK(sc);
-	if (if_getflags(ifp, IF_FLAGS) & IFF_UP)
+	if (if_get(ifp, IF_FLAGS) & IFF_UP)
 		vtnet_init_locked(sc);
 	sc->vtnet_flags &= ~VTNET_FLAG_SUSPENDED;
 	VTNET_CORE_UNLOCK(sc);
@@ -1001,7 +1001,7 @@ vtnet_change_mtu(struct vtnet_softc *sc,
 	} else
 		clsize = MJUMPAGESIZE;
 
-	if_setflags(ifp, IF_MTU, new_mtu);
+	if_set(ifp, IF_MTU, new_mtu);
 	sc->vtnet_rx_new_clsize = clsize;
 
 	if (sc->vtnet_flags & VTNET_FLAG_RUNNING) {
@@ -1025,7 +1025,7 @@ vtnet_ioctl(if_t ifp, u_long cmd, caddr_
 
 	switch (cmd) {
 	case SIOCSIFMTU:
-		if (if_getflags(ifp, IF_MTU) != ifr->ifr_mtu) {
+		if (if_get(ifp, IF_MTU) != ifr->ifr_mtu) {
 			VTNET_CORE_LOCK(sc);
 			error = vtnet_change_mtu(sc, ifr->ifr_mtu);
 			VTNET_CORE_UNLOCK(sc);
@@ -1034,11 +1034,11 @@ vtnet_ioctl(if_t ifp, u_long cmd, caddr_
 
 	case SIOCSIFFLAGS:
 		VTNET_CORE_LOCK(sc);
-		if ((if_getflags(ifp, IF_FLAGS) & IFF_UP) == 0) {
+		if ((if_get(ifp, IF_FLAGS) & IFF_UP) == 0) {
 			if (sc->vtnet_flags & VTNET_FLAG_RUNNING)
 				vtnet_stop(sc);
 		} else if (sc->vtnet_flags & VTNET_FLAG_RUNNING) {
-			if ((if_getflags(ifp, IF_FLAGS) ^ sc->vtnet_if_flags) &
+			if ((if_get(ifp, IF_FLAGS) ^ sc->vtnet_if_flags) &
 			    (IFF_PROMISC | IFF_ALLMULTI)) {
 				if (sc->vtnet_flags & VTNET_FLAG_CTRL_RX)
 					vtnet_rx_filter(sc);
@@ -1049,7 +1049,7 @@ vtnet_ioctl(if_t ifp, u_long cmd, caddr_
 			vtnet_init_locked(sc);
 
 		if (error == 0)
-			sc->vtnet_if_flags = if_getflags(ifp, IF_FLAGS);
+			sc->vtnet_if_flags = if_get(ifp, IF_FLAGS);
 		VTNET_CORE_UNLOCK(sc);
 		break;
 
@@ -1070,7 +1070,7 @@ vtnet_ioctl(if_t ifp, u_long cmd, caddr_
 
 	case SIOCSIFCAP:
 		VTNET_CORE_LOCK(sc);
-		capenable = if_getflags(ifp, IF_CAPENABLE);
+		capenable = if_get(ifp, IF_CAPENABLE);
 		mask = ifr->ifr_reqcap ^ capenable;
 
 		if (mask & IFCAP_TXCSUM)
@@ -1110,7 +1110,7 @@ vtnet_ioctl(if_t ifp, u_long cmd, caddr_
 
 		VTNET_CORE_UNLOCK(sc);
 
-		if_capenable(ifp, capenable);
+		if_set(ifp, IF_CAPENABLE, capenable);
 
 		break;
 
@@ -1653,7 +1653,7 @@ vtnet_rxq_input(struct vtnet_rxq *rxq, s
 	sc = rxq->vtnrx_sc;
 	ifp = sc->vtnet_ifp;
 
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWTAGGING) {
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWTAGGING) {
 		eh = mtod(m, struct ether_header *);
 		if (eh->ether_type == htons(ETHERTYPE_VLAN)) {
 			vtnet_vlan_tag_remove(m);
@@ -2711,8 +2711,8 @@ vtnet_virtio_reinit(struct vtnet_softc *
 	 * features. Transmit features are disabled only on our side
 	 * via IF_CAPEANBLE and IF_HWASSIST.
 	 */
-	caps = if_getflags(ifp, IF_CAPABILITIES);
-	capenable = if_getflags(ifp, IF_CAPENABLE);
+	caps = if_get(ifp, IF_CAPABILITIES);
+	capenable = if_get(ifp, IF_CAPENABLE);
 	if (caps & mask) {
 		/*
 		 * We require both IPv4 and IPv6 offloading to be enabled
@@ -2754,7 +2754,7 @@ vtnet_init_rx_filters(struct vtnet_softc
 		vtnet_rx_filter_mac(sc);
 	}
 
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWFILTER)
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWFILTER)
 		vtnet_rx_filter_vlan(sc);
 }
 
@@ -2883,15 +2883,15 @@ vtnet_reinit(struct vtnet_softc *sc)
 	vtnet_set_active_vq_pairs(sc);
 
 	hwassist = 0;
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TXCSUM)
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_TXCSUM)
 		hwassist |= VTNET_CSUM_OFFLOAD;
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TXCSUM_IPV6)
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_TXCSUM_IPV6)
 		hwassist |= VTNET_CSUM_OFFLOAD_IPV6;
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TSO4)
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_TSO4)
 		hwassist |= CSUM_TSO;
-	if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TSO6)
+	if (if_get(ifp, IF_CAPENABLE) & IFCAP_TSO6)
 		hwassist |= CSUM_IP6_TSO;
-	if_setflags(ifp, IF_HWASSIST, hwassist);
+	if_set(ifp, IF_HWASSIST, hwassist);
 
 	if (sc->vtnet_flags & VTNET_FLAG_CTRL_VQ)
 		vtnet_init_rx_filters(sc);
@@ -3140,15 +3140,15 @@ vtnet_rx_filter(struct vtnet_softc *sc)
 	VTNET_CORE_LOCK_ASSERT(sc);
 
 	if (vtnet_set_promisc(sc,
-	    if_getflags(ifp, IF_FLAGS) & IFF_PROMISC) != 0)
+	    if_get(ifp, IF_FLAGS) & IFF_PROMISC) != 0)
 		device_printf(dev, "cannot %s promiscuous mode\n",
-		    if_getflags(ifp, IF_FLAGS) & IFF_PROMISC ?
+		    if_get(ifp, IF_FLAGS) & IFF_PROMISC ?
 		    "enable" : "disable");
 
 	if (vtnet_set_allmulti(sc,
-	    if_getflags(ifp, IF_FLAGS) & IFF_ALLMULTI) != 0)
+	    if_get(ifp, IF_FLAGS) & IFF_ALLMULTI) != 0)
 		device_printf(dev, "cannot %s all-multicast mode\n",
-		    if_getflags(ifp, IF_FLAGS) & IFF_ALLMULTI ?
+		    if_get(ifp, IF_FLAGS) & IFF_ALLMULTI ?
 		    "enable" : "disable");
 }
 
@@ -3345,7 +3345,7 @@ vtnet_update_vlan_filter(struct vtnet_so
 	else
 		sc->vtnet_vlan_filter[idx] &= ~(1 << bit);
 
-	if ((if_getflags(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWFILTER) &&
+	if ((if_get(ifp, IF_CAPENABLE) & IFCAP_VLAN_HWFILTER) &&
 	    vtnet_exec_vlan_filter(sc, add, tag) != 0) {
 		device_printf(sc->vtnet_dev,
 		    "cannot %s VLAN %d %s the host filter table\n",
@@ -3385,7 +3385,7 @@ vtnet_is_link_up(struct vtnet_softc *sc)
 	dev = sc->vtnet_dev;
 	ifp = sc->vtnet_ifp;
 
-	if ((if_getflags(ifp, IF_CAPABILITIES) & IFCAP_LINKSTATE) == 0)
+	if ((if_get(ifp, IF_CAPABILITIES) & IFCAP_LINKSTATE) == 0)
 		status = VIRTIO_NET_S_LINK_UP;
 	else
 		status = virtio_read_dev_config_2(dev,

Modified: projects/ifnet/sys/net/if.c
==============================================================================
--- projects/ifnet/sys/net/if.c	Mon Jan 12 13:14:37 2015	(r277067)
+++ projects/ifnet/sys/net/if.c	Mon Jan 12 13:21:23 2015	(r277068)
@@ -1505,18 +1505,23 @@ if_rtdel(struct radix_node *rn, void *ar
  * Managing different integer values and bitmasks of an ifnet.
  */
 static void
-if_getfeature(if_t ifp, ift_feature f, uint32_t **f32, uint64_t **f64,
-    void **ptr)
+if_getfeature(if_t ifp, ift_feature f, uint64_t **f64, void **ptr,
+    uint32_t **f32, uint16_t **f16)
 {
 
-	if (f32)
-		*f32 = NULL;
 	if (f64)
 		*f64 = NULL;
 	if (ptr)
 		*ptr = NULL;
+	if (f32)
+		*f32 = NULL;
+	if (f16)
+		*f16 = NULL;
 
 	switch (f) {
+	case IF_INDEX:
+		*f16 = &ifp->if_index;
+		break;
 	case IF_FLAGS:
 		*f32 = &ifp->if_flags;
 		break;
@@ -1529,24 +1534,74 @@ if_getfeature(if_t ifp, ift_feature f, u
 	case IF_MTU:
 		*f32 = &ifp->if_mtu;
 		break;
+	case IF_FIB:
+		*f32 = &ifp->if_fib;
+		break;
 	case IF_HWASSIST:
 		*f64 = &ifp->if_hwassist;
 		break;
 	case IF_BAUDRATE:
 		*f64 = &ifp->if_baudrate;
 		break;
+	case IF_DRIVER_SOFTC:
+		*ptr = ifp->if_softc;
+		break;
+	case IF_LLADDR:
+		*ptr = LLADDR((struct sockaddr_dl *)(ifp->if_addr->ifa_addr));
+		break;
+	case IF_BPF:
+		*ptr = ifp->if_bpf;
+		break;
+	case IF_NAME:
+		*ptr = ifp->if_xname;
+		break;
 	default:
 		panic("%s: unknown feature %d", __func__, f);
 	};
 }
 
+/* Changing some flags may require some actions. */
+static void
+if_set_special(if_t ifp, ift_feature f)
+{
+
+	switch (f) {
+	case IF_CAPABILITIES:
+	{
+		uint64_t capabilities, capenable;
+		/*
+		 * If IF_CAPABILITIES have been reduced, then IF_CAPENABLE
+		 * should be reduced, too.
+		 */
+		capabilities = if_get(ifp, IF_CAPABILITIES);
+		capenable = if_get(ifp, IF_CAPENABLE);
+		if ((capenable & capabilities) != capenable) {
+			capenable &= capabilities;
+			if_set(ifp, IF_CAPENABLE, capenable);
+		}
+		break;
+	}
+	case IF_CAPENABLE:
+		/*
+		 * Modifying if_capenable may require extra actions, e.g.
+		 * reconfiguring capenable on vlans.
+		 */
+		if (ifp->if_vlantrunk != NULL)
+			(*vlan_trunk_cap_p)(ifp); 
+		break;
+	default:
+		break;
+	}
+}
+
 void
-if_setflags(if_t ifp, ift_feature f, uint64_t set)
+if_set(if_t ifp, ift_feature f, uint64_t set)
 {
 	uint64_t *f64;
 	uint32_t *f32;
 
-	if_getfeature(ifp, f, &f32, &f64, NULL);
+	if_getfeature(ifp, f, &f64, NULL, &f32, NULL);
+	KASSERT(f32 != NULL || f64 != NULL, ("%s: no feature %d", __func__, f));
 	if (f32 != NULL) {
 		KASSERT(set <= UINT32_MAX,
 		    ("%s: value of 0x%jx for feature %d",
@@ -1555,30 +1610,16 @@ if_setflags(if_t ifp, ift_feature f, uin
 	} else {
 		*f64 = set;
 	}
+	if_set_special(ifp, f);
 }
 
 uint64_t
 if_flagbits(if_t ifp, ift_feature f, uint64_t set, uint64_t clr, uint64_t xor)
 {
-	uint64_t *f64;
+	uint64_t *f64, rv, old;
 	uint32_t *f32;
 
-#ifdef INVARIANTS
-	switch (f) {
-	case IF_CAPABILITIES:
-		if (set || clr || xor)
-			panic("IF_CAPABILITIES can't be modified");
-		break;
-	case IF_CAPENABLE:
-		if (set || clr || xor)
-			panic("IF_CAPENABLE must be modified by if_capenable");
-		break;
-	default:
-		break;
-	}
-#endif
-
-	if_getfeature(ifp, f, &f32, &f64, NULL);
+	if_getfeature(ifp, f, &f64, NULL, &f32, NULL);
 	if (f32 != NULL) {
 		KASSERT(set <= UINT32_MAX,
 		    ("%s: value of 0x%jx for feature %d",
@@ -1589,54 +1630,52 @@ if_flagbits(if_t ifp, ift_feature f, uin
 		KASSERT(xor <= UINT32_MAX,
 		    ("%s: value of 0x%jx for feature %d",
 		    __func__, (uintmax_t )xor, f));
+		old = *f32;
 		*f32 |= set;
 		*f32 &= ~clr;
 		*f32 ^= xor;
-		return (*f32);
+		rv = *f32;
 	} else {
+		old = *f64;
 		*f64 |= set;
 		*f64 &= ~clr;
 		*f64 ^= xor;
-		return (*f64);
+		rv = *f64;
 	}
+
+	if (rv != old)
+		if_set_special(ifp, f);
+
+	return (rv);
 }
 
-/*
- * Modifying if_capenable may require extra actions, e.g. reconfiguring
- * capenable on vlans.
- */
-void
-if_capenable(if_t ifp, uint64_t capenable)
+uint64_t
+if_get(if_t ifp, ift_feature f)
 {
+	uint64_t *f64;
+	uint32_t *f32;
+	uint16_t *f16;
 
-	KASSERT(capenable <= UINT32_MAX, ("%s: extra bits in 0x%jx",
-	    __func__, (uintmax_t )capenable));
-
-	ifp->if_capenable = capenable;
+	if_getfeature(ifp, f, &f64, NULL, &f32, &f16);
+	KASSERT(f16 != NULL || f32 != NULL || f64 != NULL,
+	    ("%s: no feature %d", __func__, f));
+	if (f64 != NULL)
+		return (*f64);
+	if (f32 != NULL)
+		return (*f32);
+	if (f16 != NULL)
+		return (*f16);
 
-	if (ifp->if_vlantrunk != NULL)
-		(*vlan_trunk_cap_p)(ifp); 
+	return (EDOOFUS);
 }
 
 void *
 if_getsoftc(if_t ifp, ift_feature f)
 {
+	void *ptr;
 
-	switch (f) {
-	case IF_DRIVER_SOFTC:
-		return (ifp->if_softc);
-	default:
-		panic("%s: unknown feature %d", __func__, f);
-	}
-}
-
-char *
-if_lladdr(if_t ifp)
-{
-	struct sockaddr_dl *sdl;
-
-	sdl = (struct sockaddr_dl *)(ifp->if_addr->ifa_addr);
-	return (LLADDR(sdl));
+	if_getfeature(ifp, f, NULL, &ptr, NULL, NULL);
+	return (ptr);
 }
 
 /*

Modified: projects/ifnet/sys/net/if.h
==============================================================================
--- projects/ifnet/sys/net/if.h	Mon Jan 12 13:14:37 2015	(r277067)
+++ projects/ifnet/sys/net/if.h	Mon Jan 12 13:21:23 2015	(r277068)
@@ -568,16 +568,22 @@ typedef enum {
 } ift_counter;
 
 typedef enum {
+	/* uint16_t */
+	IF_INDEX,
 	/* uint32_t */
-	IF_FLAGS = 1,
+	IF_FLAGS,
 	IF_CAPABILITIES,
 	IF_CAPENABLE,
 	IF_MTU,
+	IF_FIB,
 	/* uint64_t */
 	IF_HWASSIST,
 	IF_BAUDRATE,
 	/* pointers */
 	IF_DRIVER_SOFTC,
+	IF_LLADDR,
+	IF_BPF,
+	IF_NAME,
 } ift_feature;
 
 typedef struct ifnet * if_t;
@@ -701,18 +707,14 @@ void	if_detach(if_t);
 void	if_input(if_t, struct mbuf *);
 void	if_mtap(if_t, struct mbuf *, void *, u_int);
 void	if_inc_counter(if_t, ift_counter, int64_t);
-uint64_t if_get_counter_default(if_t, ift_counter);
 void	if_link_state_change(if_t, int);
+void	if_set(if_t, ift_feature, uint64_t);
 void *	if_getsoftc(if_t, ift_feature);
-char *	if_lladdr(if_t);
-void	if_setflags(if_t, ift_feature, uint64_t);
-uint64_t if_flagbits(if_t, ift_feature, uint64_t, uint64_t, uint64_t);
-#define	if_getflags(ifp, f)	if_flagbits((ifp), (f), 0, 0, 0)
-#define	if_addflags(ifp, f, a)	if_flagbits((ifp), (f), (a), 0, 0)
-#define	if_clrflags(ifp, f, c)	if_flagbits((ifp), (f), 0, (c), 0)
-#define	if_xorflags(ifp, f, x)	if_flagbits((ifp), (f), 0, 0, (x))
-void	if_capenable(if_t, uint64_t);
 int	if_printf(if_t, const char *, ...) __printflike(2, 3);
+uint64_t if_get(if_t, ift_feature);
+uint64_t if_flagbits(if_t, ift_feature, uint64_t, uint64_t, uint64_t);
+uint64_t if_get_counter_default(if_t, ift_counter);
+
 /*
  * Traversing through interface address lists.
  */
@@ -722,5 +724,42 @@ typedef	void	ifmaddr_cb_t(void *, struct
 void	if_foreach_addr(if_t, ifaddr_cb_t, void *);
 void	if_foreach_maddr(if_t, ifmaddr_cb_t, void *);
 
+/*
+ * Type-enforcing inliners over declared above functions.
+ */
+static inline uint64_t
+if_addflags(if_t ifp, ift_feature f, uint64_t add)
+{
+
+	return (if_flagbits(ifp, f, add, 0, 0));
+}
+
+static inline uint64_t
+if_clrflags(if_t ifp, ift_feature f, uint64_t clr)
+{
+
+	return (if_flagbits(ifp, f, 0, clr, 0));
+}
+
+static inline uint64_t
+if_xorflags(if_t ifp, ift_feature f, uint64_t xor)
+{
+
+	return (if_flagbits(ifp, f, 0, 0, xor));
+}
+
+static inline char *
+if_lladdr(if_t ifp)
+{
+
+	return ((char *)(if_getsoftc(ifp, IF_LLADDR)));
+}
+
+static inline const char *
+if_name(if_t ifp)
+{
+
+	return ((char *)(if_getsoftc(ifp, IF_NAME)));
+}
 #endif /* _KERNEL */
 #endif /* !_NET_IF_H_ */

Modified: projects/ifnet/sys/net/if_loop.c
==============================================================================
--- projects/ifnet/sys/net/if_loop.c	Mon Jan 12 13:14:37 2015	(r277067)
+++ projects/ifnet/sys/net/if_loop.c	Mon Jan 12 13:21:23 2015	(r277068)
@@ -241,7 +241,7 @@ looutput(if_t ifp, struct mbuf *m, const
 #if 1	/* XXX */
 	switch (af) {
 	case AF_INET:
-		if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_RXCSUM) {
+		if (if_get(ifp, IF_CAPENABLE) & IFCAP_RXCSUM) {
 			m->m_pkthdr.csum_data = 0xffff;
 			m->m_pkthdr.csum_flags = LO_CSUM_SET;
 		}
@@ -396,22 +396,21 @@ loioctl(if_t ifp, u_long cmd, caddr_t da
 		break;
 
 	case SIOCSIFMTU:
-		if_setflags(ifp, IF_MTU, ifr->ifr_mtu);
+		if_set(ifp, IF_MTU, ifr->ifr_mtu);
 		break;
 
 	case SIOCSIFFLAGS:
 		break;
 
 	case SIOCSIFCAP:
-		mask = if_getflags(ifp, IF_CAPENABLE) ^ ifr->ifr_reqcap;
+		mask = if_get(ifp, IF_CAPENABLE) ^ ifr->ifr_reqcap;
 		if ((mask & IFCAP_RXCSUM) != 0)
 			if_xorflags(ifp, IF_CAPENABLE, IFCAP_RXCSUM);
 		if ((mask & IFCAP_TXCSUM) != 0)
 			if_xorflags(ifp, IF_CAPENABLE, IFCAP_TXCSUM);
 		if ((mask & IFCAP_RXCSUM_IPV6) != 0) {
 #if 0
-			if_xorflags(ifp, IF_CAPENABLE,
-			    IFCAP_RXCSUM_IPV6);
+			if_xorflags(ifp, IF_CAPENABLE, IFCAP_RXCSUM_IPV6);
 #else
 			error = EOPNOTSUPP;
 			break;
@@ -419,18 +418,17 @@ loioctl(if_t ifp, u_long cmd, caddr_t da
 		}
 		if ((mask & IFCAP_TXCSUM_IPV6) != 0) {
 #if 0
-			if_xorflags(ifp, IF_CAPENABLE,
-			    IFCAP_TXCSUM_IPV6);
+			if_xorflags(ifp, IF_CAPENABLE, IFCAP_TXCSUM_IPV6);
 #else
 			error = EOPNOTSUPP;
 			break;
 #endif
 		}
-		if_setflags(ifp, IF_HWASSIST, 0);
-		if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TXCSUM)
-			if_setflags(ifp, IF_HWASSIST, LO_CSUM_FEATURES);
+		if_set(ifp, IF_HWASSIST, 0);
+		if (if_get(ifp, IF_CAPENABLE) & IFCAP_TXCSUM)
+			if_set(ifp, IF_HWASSIST, LO_CSUM_FEATURES);
 #if 0
-		if (if_getflags(ifp, IF_CAPENABLE) & IFCAP_TXCSUM_IPV6)
+		if (if_get(ifp, IF_CAPENABLE) & IFCAP_TXCSUM_IPV6)
 			if_addflags(ifp, IF_HWASSIST, LO_CSUM_FEATURES6);
 #endif
 		break;

Modified: projects/ifnet/sys/net/if_var.h
==============================================================================
--- projects/ifnet/sys/net/if_var.h	Mon Jan 12 13:14:37 2015	(r277067)
+++ projects/ifnet/sys/net/if_var.h	Mon Jan 12 13:21:23 2015	(r277068)
@@ -527,13 +527,6 @@ if_addrlen(const if_t ifp)
 
 	return (ifp->if_drv->ifdrv_addrlen);
 }
-
-static inline const char *
-if_name(if_t ifp)
-{
-
-	return (ifp->if_xname);
-}
 #endif /* _KERNEL */
 
 #include <net/ifq.h>	/* XXXAO: temporary unconditional include */



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