FreeBSD/sys/dev/ixgbe/if_ixv.c
/*********************************************************************
 *  Ioctl entry point
 *
 *  ixv_ioctl is called when the user wants to configure the
 *  interface.
 *
 *  return 0 on success, positive on failure
 **********************************************************************/
Ioctl entry point
ixv_ioctl is called when the user wants to configure the
interface.

return 0 on success, positive on failure
Ioctl entry point ixv_ioctl is called when the user wants to configure the interface . return 0 on success positive on failure
static int
ixv_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
{
	struct adapter	*adapter = ifp->if_softc;
	struct ifreq	*ifr = (struct ifreq *) data;
#if defined(INET) || defined(INET6)
	struct ifaddr	*ifa = (struct ifaddr *) data;
	bool		avoid_reset = FALSE;
#endif
	int             error = 0;
	switch (command) {
	case SIOCSIFADDR:
#ifdef INET
		if (ifa->ifa_addr->sa_family == AF_INET)
			avoid_reset = TRUE;
#endif
#ifdef INET6
		if (ifa->ifa_addr->sa_family == AF_INET6)
			avoid_reset = TRUE;
#endif
#if defined(INET) || defined(INET6)
		if (avoid_reset) {
			ifp->if_flags |= IFF_UP;
			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
				ixv_init(adapter);
			if (!(ifp->if_flags & IFF_NOARP))
				arp_ifinit(ifp, ifa);
		} else
			error = ether_ioctl(ifp, command, data);
		break;
#endif
	case SIOCSIFMTU:
		IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
		if (ifr->ifr_mtu > IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR) {
			error = EINVAL;
		} else {
			IXGBE_CORE_LOCK(adapter);
			ifp->if_mtu = ifr->ifr_mtu;
			adapter->max_frame_size =
				ifp->if_mtu + IXGBE_MTU_HDR;
			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
				ixv_init_locked(adapter);
			IXGBE_CORE_UNLOCK(adapter);
		}
		break;
	case SIOCSIFFLAGS:
		IOCTL_DEBUGOUT("ioctl: SIOCSIFFLAGS (Set Interface Flags)");
		IXGBE_CORE_LOCK(adapter);
		if (ifp->if_flags & IFF_UP) {
			if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
				ixv_init_locked(adapter);
		} else
			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
				ixv_stop(adapter);
		adapter->if_flags = ifp->if_flags;
		IXGBE_CORE_UNLOCK(adapter);
		break;
	case SIOCADDMULTI:
	case SIOCDELMULTI:
		IOCTL_DEBUGOUT("ioctl: SIOC(ADD|DEL)MULTI");
		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
			IXGBE_CORE_LOCK(adapter);
			ixv_disable_intr(adapter);
			ixv_set_multi(adapter);
			ixv_enable_intr(adapter);
			IXGBE_CORE_UNLOCK(adapter);
		}
		break;
	case SIOCSIFMEDIA:
	case SIOCGIFMEDIA:
		IOCTL_DEBUGOUT("ioctl: SIOCxIFMEDIA (Get/Set Interface Media)");
		error = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
		break;
	case SIOCSIFCAP:
	{
		int mask = ifr->ifr_reqcap ^ ifp->if_capenable;
		IOCTL_DEBUGOUT("ioctl: SIOCSIFCAP (Set Capabilities)");
		if (mask & IFCAP_HWCSUM)
			ifp->if_capenable ^= IFCAP_HWCSUM;
		if (mask & IFCAP_TSO4)
			ifp->if_capenable ^= IFCAP_TSO4;
		if (mask & IFCAP_LRO)
			ifp->if_capenable ^= IFCAP_LRO;
		if (mask & IFCAP_VLAN_HWTAGGING)
			ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
			IXGBE_CORE_LOCK(adapter);
			ixv_init_locked(adapter);
			IXGBE_CORE_UNLOCK(adapter);
		}
		VLAN_CAPABILITIES(ifp);
		break;
	}
	default:
		IOCTL_DEBUGOUT1("ioctl: UNKNOWN (0x%X)\n", (int)command);
		error = ether_ioctl(ifp, command, data);
		break;
	}
	return (error);
}
static int ixv_ioctl ( struct ifnet * ifp , u_long command , caddr_t data ) { struct adapter * adapter = ifp -> if_softc ; struct ifreq * ifr = ( struct ifreq * ) data ; #if defined ( INET ) || defined ( INET6 ) struct ifaddr * ifa = ( struct ifaddr * ) data ; bool avoid_reset = FALSE ; #endif int error = 0 ; switch ( command ) { case SIOCSIFADDR : #ifdef INET if ( ifa -> ifa_addr -> sa_family == AF_INET ) avoid_reset = TRUE ; #endif #ifdef INET6 if ( ifa -> ifa_addr -> sa_family == AF_INET6 ) avoid_reset = TRUE ; #endif #if defined ( INET ) || defined ( INET6 ) if ( avoid_reset ) { ifp -> if_flags |= IFF_UP ; if ( ! ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) ) ixv_init ( adapter ) ; if ( ! ( ifp -> if_flags & IFF_NOARP ) ) arp_ifinit ( ifp , ifa ) ; } else error = ether_ioctl ( ifp , command , data ) ; break ; #endif case SIOCSIFMTU : IOCTL_DEBUGOUT ( " " ) ; if ( ifr -> ifr_mtu > IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR ) { error = EINVAL ; } else { IXGBE_CORE_LOCK ( adapter ) ; ifp -> if_mtu = ifr -> ifr_mtu ; adapter -> max_frame_size = ifp -> if_mtu + IXGBE_MTU_HDR ; if ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) ixv_init_locked ( adapter ) ; IXGBE_CORE_UNLOCK ( adapter ) ; } break ; case SIOCSIFFLAGS : IOCTL_DEBUGOUT ( " " ) ; IXGBE_CORE_LOCK ( adapter ) ; if ( ifp -> if_flags & IFF_UP ) { if ( ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) == 0 ) ixv_init_locked ( adapter ) ; } else if ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) ixv_stop ( adapter ) ; adapter -> if_flags = ifp -> if_flags ; IXGBE_CORE_UNLOCK ( adapter ) ; break ; case SIOCADDMULTI : case SIOCDELMULTI : IOCTL_DEBUGOUT ( " " ) ; if ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) { IXGBE_CORE_LOCK ( adapter ) ; ixv_disable_intr ( adapter ) ; ixv_set_multi ( adapter ) ; ixv_enable_intr ( adapter ) ; IXGBE_CORE_UNLOCK ( adapter ) ; } break ; case SIOCSIFMEDIA : case SIOCGIFMEDIA : IOCTL_DEBUGOUT ( " " ) ; error = ifmedia_ioctl ( ifp , ifr , & adapter -> media , command ) ; break ; case SIOCSIFCAP : { int mask = ifr -> ifr_reqcap ^ ifp -> if_capenable ; IOCTL_DEBUGOUT ( " " ) ; if ( mask & IFCAP_HWCSUM ) ifp -> if_capenable ^= IFCAP_HWCSUM ; if ( mask & IFCAP_TSO4 ) ifp -> if_capenable ^= IFCAP_TSO4 ; if ( mask & IFCAP_LRO ) ifp -> if_capenable ^= IFCAP_LRO ; if ( mask & IFCAP_VLAN_HWTAGGING ) ifp -> if_capenable ^= IFCAP_VLAN_HWTAGGING ; if ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) { IXGBE_CORE_LOCK ( adapter ) ; ixv_init_locked ( adapter ) ; IXGBE_CORE_UNLOCK ( adapter ) ; } VLAN_CAPABILITIES ( ifp ) ; break ; } default : IOCTL_DEBUGOUT1 ( " \n " , ( int ) command ) ; error = ether_ioctl ( ifp , command , data ) ; break ; } return ( error ) ; }
Ioctl entry point
  ixv_ioctl is called when the user wants to configure the
  interface.
Ioctl entry point ixv_ioctl is called when the user wants to configure the interface .
/*
		** Calling init results in link renegotiation,
		** so we avoid doing it when possible.
		*/