Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2017 16:12:31 +0000 (UTC)
From:      "Stephen J. Kiernan" <stevek@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r313019 - in head/sys: dev/e1000 dev/vnic net
Message-ID:  <201701311612.v0VGCVsd038606@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: stevek
Date: Tue Jan 31 16:12:31 2017
New Revision: 313019
URL: https://svnweb.freebsd.org/changeset/base/313019

Log:
  Add the folowing set accessor functions for recently-added members of ifnet
  structure:
  
  if_gethwtsomax(), if_sethwtsomax()                 - if_hw_tsomax
  if_gethwtsomaxsegcount(), if_sethwtsomaxsegcount() - if_hw_tsomaxsegcount
  if_gethwtsomaxsegsize(), if_sethwtsomaxsegsize()   - if_hw_tsomaxsegsize
  
  Update em and vnic drivers which had already been coverted to use accessor
  functions for the other ifnet structure members.
  
  Reviewed by:	erj
  Approved by:	sjg (mentor)
  Obtained from:	Juniper Networks, Inc.
  Differential Revision:	https://reviews.freebsd.org/D8544

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/vnic/nicvf_main.c
  head/sys/net/if.c
  head/sys/net/if_var.h

Modified: head/sys/dev/e1000/if_em.c
==============================================================================
--- head/sys/dev/e1000/if_em.c	Tue Jan 31 15:35:18 2017	(r313018)
+++ head/sys/dev/e1000/if_em.c	Tue Jan 31 16:12:31 2017	(r313019)
@@ -2481,10 +2481,10 @@ em_setup_interface(if_ctx_t ctx)
 	INIT_DEBUGOUT("em_setup_interface: begin");
 
 	/* TSO parameters */
-	ifp->if_hw_tsomax = IP_MAXPACKET;
+	if_sethwtsomax(ifp, IP_MAXPACKET);
 	/* Take m_pullup(9)'s in em_xmit() w/ TSO into acount. */
-	ifp->if_hw_tsomaxsegcount = EM_MAX_SCATTER - 5;
-	ifp->if_hw_tsomaxsegsize = EM_TSO_SEG_SIZE;
+	if_sethwtsomaxsegcount(ifp, EM_MAX_SCATTER - 5);
+	if_sethwtsomaxsegsize(ifp, EM_TSO_SEG_SIZE);
 
 	/* Single Queue */
         if (adapter->tx_num_queues == 1) {

Modified: head/sys/dev/vnic/nicvf_main.c
==============================================================================
--- head/sys/dev/vnic/nicvf_main.c	Tue Jan 31 15:35:18 2017	(r313018)
+++ head/sys/dev/vnic/nicvf_main.c	Tue Jan 31 16:12:31 2017	(r313019)
@@ -370,9 +370,9 @@ nicvf_setup_ifnet(struct nicvf *nic)
 		/* TSO */
 		if_setcapabilitiesbit(ifp, IFCAP_TSO4, 0);
 		/* TSO parameters */
-		ifp->if_hw_tsomax = NICVF_TSO_MAXSIZE;
-		ifp->if_hw_tsomaxsegcount = NICVF_TSO_NSEGS;
-		ifp->if_hw_tsomaxsegsize = MCLBYTES;
+		if_sethwtsomax(ifp, NICVF_TSO_MAXSIZE);
+		if_sethwtsomaxsegcount(ifp, NICVF_TSO_NSEGS);
+		if_sethwtsomaxsegsize(ifp, MCLBYTES);
 	}
 	/* IP/TCP/UDP HW checksums */
 	if_setcapabilitiesbit(ifp, IFCAP_HWCSUM, 0);
@@ -453,7 +453,7 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 #if defined(INET) || defined(INET6)
 		/* Avoid reinitialization unless it's necessary */
 		if (avoid_reset) {
-			ifp->if_flags |= IFF_UP;
+			if_setflagbits(ifp, IFF_UP, 0);
 			if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
 				nicvf_if_init(nic);
 #ifdef INET
@@ -482,8 +482,8 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 		NICVF_CORE_LOCK(nic);
 		if (if_getflags(ifp) & IFF_UP) {
 			if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
-				flags = ifp->if_flags ^ nic->if_flags;
-				if ((nic->if_flags & ifp->if_flags) &
+				flags = if_getflags(ifp) ^ nic->if_flags;
+				if ((nic->if_flags & if_getflags(ifp)) &
 				    IFF_PROMISC) {
 					/* Change promiscous mode */
 #if 0
@@ -492,7 +492,7 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 #endif
 				}
 
-				if ((nic->if_flags ^ ifp->if_flags) &
+				if ((nic->if_flags ^ if_getflags(ifp)) &
 				    IFF_ALLMULTI) {
 					/* Change multicasting settings */
 #if 0
@@ -506,7 +506,7 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 		} else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
 			nicvf_stop_locked(nic);
 
-		nic->if_flags = ifp->if_flags;
+		nic->if_flags = if_getflags(ifp);
 		NICVF_CORE_UNLOCK(nic);
 		break;
 
@@ -528,24 +528,24 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 		break;
 
 	case SIOCSIFCAP:
-		mask = ifp->if_capenable ^ ifr->ifr_reqcap;
+		mask = if_getcapenable(ifp) ^ ifr->ifr_reqcap;
 		if (mask & IFCAP_VLAN_MTU) {
 			/* No work to do except acknowledge the change took. */
-			ifp->if_capenable ^= IFCAP_VLAN_MTU;
+			if_togglecapenable(ifp, IFCAP_VLAN_MTU);
 		}
 		if (mask & IFCAP_TXCSUM)
-			ifp->if_capenable ^= IFCAP_TXCSUM;
+			if_togglecapenable(ifp, IFCAP_TXCSUM);
 		if (mask & IFCAP_RXCSUM)
-			ifp->if_capenable ^= IFCAP_RXCSUM;
+			if_togglecapenable(ifp, IFCAP_RXCSUM);
 		if ((mask & IFCAP_TSO4) && nic->hw_tso)
-			ifp->if_capenable ^= IFCAP_TSO4;
+			if_togglecapenable(ifp, IFCAP_TSO4);
 		if (mask & IFCAP_LRO) {
 			/*
 			 * Lock the driver for a moment to avoid
 			 * mismatch in per-queue settings.
 			 */
 			NICVF_CORE_LOCK(nic);
-			ifp->if_capenable ^= IFCAP_LRO;
+			if_togglecapenable(ifp, IFCAP_LRO);
 			if ((if_getdrvflags(nic->ifp) & IFF_DRV_RUNNING) != 0) {
 				/*
 				 * Now disable LRO for subsequent packets.

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Tue Jan 31 15:35:18 2017	(r313018)
+++ head/sys/net/if.c	Tue Jan 31 16:12:31 2017	(r313019)
@@ -4103,6 +4103,51 @@ if_vlancap(if_t ifh)
 	VLAN_CAPABILITIES(ifp);
 }
 
+int
+if_sethwtsomax(if_t ifp, u_int if_hw_tsomax)
+{
+
+	((struct ifnet *)ifp)->if_hw_tsomax = if_hw_tsomax;
+        return (0);
+}
+
+int
+if_sethwtsomaxsegcount(if_t ifp, u_int if_hw_tsomaxsegcount)
+{
+
+	((struct ifnet *)ifp)->if_hw_tsomaxsegcount = if_hw_tsomaxsegcount;
+        return (0);
+}
+
+int
+if_sethwtsomaxsegsize(if_t ifp, u_int if_hw_tsomaxsegsize)
+{
+
+	((struct ifnet *)ifp)->if_hw_tsomaxsegsize = if_hw_tsomaxsegsize;
+        return (0);
+}
+
+u_int
+if_gethwtsomax(if_t ifp)
+{
+
+	return (((struct ifnet *)ifp)->if_hw_tsomax);
+}
+
+u_int
+if_gethwtsomaxsegcount(if_t ifp)
+{
+
+	return (((struct ifnet *)ifp)->if_hw_tsomaxsegcount);
+}
+
+u_int
+if_gethwtsomaxsegsize(if_t ifp)
+{
+
+	return (((struct ifnet *)ifp)->if_hw_tsomaxsegsize);
+}
+
 void
 if_setinitfn(if_t ifp, void (*init_fn)(void *))
 {

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Tue Jan 31 15:35:18 2017	(r313018)
+++ head/sys/net/if_var.h	Tue Jan 31 16:12:31 2017	(r313019)
@@ -658,6 +658,12 @@ int if_getflags(if_t ifp);
 int if_sendq_empty(if_t ifp);
 int if_setsendqready(if_t ifp);
 int if_setsendqlen(if_t ifp, int tx_desc_count);
+int if_sethwtsomax(if_t ifp, u_int if_hw_tsomax);
+int if_sethwtsomaxsegcount(if_t ifp, u_int if_hw_tsomaxsegcount);
+int if_sethwtsomaxsegsize(if_t ifp, u_int if_hw_tsomaxsegsize);
+u_int if_gethwtsomax(if_t ifp);
+u_int if_gethwtsomaxsegcount(if_t ifp);
+u_int if_gethwtsomaxsegsize(if_t ifp);
 int if_input(if_t ifp, struct mbuf* sendmp);
 int if_sendq_prepend(if_t ifp, struct mbuf *m);
 struct mbuf *if_dequeue(if_t ifp);



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