FreeBSD/sys/dev/ixl/if_ixlv.c
/*********************************************************************
 *
 *  Setup networking device structure and register an interface.
 *
 **********************************************************************/
Setup networking device structure and register an interface.
Setup networking device structure and register an interface .
static int
ixlv_setup_interface(device_t dev, struct ixlv_sc *sc)
{
	struct ifnet		*ifp;
	struct ixl_vsi		*vsi = &sc->vsi;
	struct ixl_queue	*que = vsi->queues;
	INIT_DBG_DEV(dev, "begin");
	ifp = vsi->ifp = if_alloc(IFT_ETHER);
	if (ifp == NULL) {
		device_printf(dev, "%s: could not allocate ifnet"
		    " structure!\n", __func__);
		return (-1);
	}
	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
	ifp->if_mtu = ETHERMTU;
	ifp->if_baudrate = IF_Gbps(40);
	ifp->if_init = ixlv_init;
	ifp->if_softc = vsi;
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_ioctl = ixlv_ioctl;
#if __FreeBSD_version >= 1100000
	if_setgetcounterfn(ifp, ixl_get_counter);
#endif
	ifp->if_transmit = ixl_mq_start;
	ifp->if_qflush = ixl_qflush;
	ifp->if_snd.ifq_maxlen = que->num_desc - 2;
	ether_ifattach(ifp, sc->hw.mac.addr);
	vsi->max_frame_size =
	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN
	    + ETHER_VLAN_ENCAP_LEN;
	ifp->if_hdrlen = sizeof(struct ether_vlan_header);
	ifp->if_capabilities |= IFCAP_HWCSUM;
	ifp->if_capabilities |= IFCAP_HWCSUM_IPV6;
	ifp->if_capabilities |= IFCAP_TSO;
	ifp->if_capabilities |= IFCAP_JUMBO_MTU;
	ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING
			     |  IFCAP_VLAN_HWTSO
			     |  IFCAP_VLAN_MTU
			     |  IFCAP_VLAN_HWCSUM
			     |  IFCAP_LRO;
	ifp->if_capenable = ifp->if_capabilities;
	ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
	ifmedia_init(&sc->media, IFM_IMASK, ixlv_media_change,
		     ixlv_media_status);
	ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
	ifmedia_set(&sc->media, IFM_ETHER | IFM_AUTO);
	INIT_DBG_DEV(dev, "end");
	return (0);
}
static int ixlv_setup_interface ( device_t dev , struct ixlv_sc * sc ) { struct ifnet * ifp ; struct ixl_vsi * vsi = & sc -> vsi ; struct ixl_queue * que = vsi -> queues ; INIT_DBG_DEV ( dev , " " ) ; ifp = vsi -> ifp = if_alloc ( IFT_ETHER ) ; if ( ifp == NULL ) { device_printf ( dev , " " " \n " , __func__ ) ; return ( -1 ) ; } if_initname ( ifp , device_get_name ( dev ) , device_get_unit ( dev ) ) ; ifp -> if_mtu = ETHERMTU ; ifp -> if_baudrate = IF_Gbps ( 40 ) ; ifp -> if_init = ixlv_init ; ifp -> if_softc = vsi ; ifp -> if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST ; ifp -> if_ioctl = ixlv_ioctl ; #if __FreeBSD_version >= 1100000 if_setgetcounterfn ( ifp , ixl_get_counter ) ; #endif ifp -> if_transmit = ixl_mq_start ; ifp -> if_qflush = ixl_qflush ; ifp -> if_snd . ifq_maxlen = que -> num_desc - 2 ; ether_ifattach ( ifp , sc -> hw . mac . addr ) ; vsi -> max_frame_size = ifp -> if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN ; ifp -> if_hdrlen = sizeof ( struct ether_vlan_header ) ; ifp -> if_capabilities |= IFCAP_HWCSUM ; ifp -> if_capabilities |= IFCAP_HWCSUM_IPV6 ; ifp -> if_capabilities |= IFCAP_TSO ; ifp -> if_capabilities |= IFCAP_JUMBO_MTU ; ifp -> if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO | IFCAP_VLAN_MTU | IFCAP_VLAN_HWCSUM | IFCAP_LRO ; ifp -> if_capenable = ifp -> if_capabilities ; ifp -> if_capabilities |= IFCAP_VLAN_HWFILTER ; ifmedia_init ( & sc -> media , IFM_IMASK , ixlv_media_change , ixlv_media_status ) ; ifmedia_add ( & sc -> media , IFM_ETHER | IFM_AUTO , 0 , NULL ) ; ifmedia_set ( & sc -> media , IFM_ETHER | IFM_AUTO ) ; INIT_DBG_DEV ( dev , " " ) ; return ( 0 ) ; }
Setup networking device structure and register an interface.
Setup networking device structure and register an interface .
/*
	 * Tell the upper layer(s) we support long frames.
	 */ /*
	** Don't turn this on by default, if vlans are
	** created on another pseudo device (eg. lagg)
	** then vlan events are not passed thru, breaking
	** operation, but with HW FILTER off it works. If
	** using vlans directly on the ixl driver you can
	** enable this and get full hardware tag filtering.
	*/ /*
	 * Specify the media types supported by this adapter and register
	 * callbacks to update media and link information
	 */ // JFV Add media types later?