FreeBSD/sys/dev/qlxge/qls_os.c
/*
 * Name: qls_init_ifnet
 * Function: Creates the Network Device Interface and Registers it with the O.S
 */
qls_init_ifnet
Function: Creates the Network Device Interface and Registers it with the O.S
qls_init_ifnet Function : Creates the Network Device Interface and Registers it with the O . S
static void
qls_init_ifnet(device_t dev, qla_host_t *ha)
{
	struct ifnet *ifp;
	QL_DPRINT2((dev, "%s: enter\n", __func__));
	ifp = ha->ifp = if_alloc(IFT_ETHER);
	if (ifp == NULL)
		panic("%s: cannot if_alloc()\n", device_get_nameunit(dev));
	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
	ifp->if_baudrate = IF_Gbps(10);
	ifp->if_init = qls_init;
	ifp->if_softc = ha;
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_ioctl = qls_ioctl;
	ifp->if_start = qls_start;
	IFQ_SET_MAXLEN(&ifp->if_snd, qls_get_ifq_snd_maxlen(ha));
	ifp->if_snd.ifq_drv_maxlen = qls_get_ifq_snd_maxlen(ha);
	IFQ_SET_READY(&ifp->if_snd);
	ha->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
	if (ha->max_frame_size <= MCLBYTES) {
		ha->msize = MCLBYTES;
	} else if (ha->max_frame_size <= MJUMPAGESIZE) {
		ha->msize = MJUMPAGESIZE;
	} else
		ha->msize = MJUM9BYTES;
	ether_ifattach(ifp, qls_get_mac_addr(ha));
	ifp->if_capabilities = IFCAP_JUMBO_MTU;
	ifp->if_capabilities |= IFCAP_HWCSUM;
	ifp->if_capabilities |= IFCAP_VLAN_MTU;
	ifp->if_capabilities |= IFCAP_TSO4;
	ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
	ifp->if_capabilities |= IFCAP_VLAN_HWTSO;
	ifp->if_capabilities |= IFCAP_LINKSTATE;
	ifp->if_capenable = ifp->if_capabilities;
	ifp->if_hdrlen = sizeof(struct ether_vlan_header);
	ifmedia_init(&ha->media, IFM_IMASK, qls_media_change, qls_media_status);
	ifmedia_add(&ha->media, (IFM_ETHER | qls_get_optics(ha) | IFM_FDX), 0,
		NULL);
	ifmedia_add(&ha->media, (IFM_ETHER | IFM_AUTO), 0, NULL);
	ifmedia_set(&ha->media, (IFM_ETHER | IFM_AUTO));
	QL_DPRINT2((dev, "%s: exit\n", __func__));
	return;
}
static void qls_init_ifnet ( device_t dev , qla_host_t * ha ) { struct ifnet * ifp ; QL_DPRINT2 ( ( dev , " \n " , __func__ ) ) ; ifp = ha -> ifp = if_alloc ( IFT_ETHER ) ; if ( ifp == NULL ) panic ( " \n " , device_get_nameunit ( dev ) ) ; if_initname ( ifp , device_get_name ( dev ) , device_get_unit ( dev ) ) ; ifp -> if_baudrate = IF_Gbps ( 10 ) ; ifp -> if_init = qls_init ; ifp -> if_softc = ha ; ifp -> if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST ; ifp -> if_ioctl = qls_ioctl ; ifp -> if_start = qls_start ; IFQ_SET_MAXLEN ( & ifp -> if_snd , qls_get_ifq_snd_maxlen ( ha ) ) ; ifp -> if_snd . ifq_drv_maxlen = qls_get_ifq_snd_maxlen ( ha ) ; IFQ_SET_READY ( & ifp -> if_snd ) ; ha -> max_frame_size = ifp -> if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN ; if ( ha -> max_frame_size <= MCLBYTES ) { ha -> msize = MCLBYTES ; } else if ( ha -> max_frame_size <= MJUMPAGESIZE ) { ha -> msize = MJUMPAGESIZE ; } else ha -> msize = MJUM9BYTES ; ether_ifattach ( ifp , qls_get_mac_addr ( ha ) ) ; ifp -> if_capabilities = IFCAP_JUMBO_MTU ; ifp -> if_capabilities |= IFCAP_HWCSUM ; ifp -> if_capabilities |= IFCAP_VLAN_MTU ; ifp -> if_capabilities |= IFCAP_TSO4 ; ifp -> if_capabilities |= IFCAP_VLAN_HWTAGGING ; ifp -> if_capabilities |= IFCAP_VLAN_HWTSO ; ifp -> if_capabilities |= IFCAP_LINKSTATE ; ifp -> if_capenable = ifp -> if_capabilities ; ifp -> if_hdrlen = sizeof ( struct ether_vlan_header ) ; ifmedia_init ( & ha -> media , IFM_IMASK , qls_media_change , qls_media_status ) ; ifmedia_add ( & ha -> media , ( IFM_ETHER | qls_get_optics ( ha ) | IFM_FDX ) , 0 , NULL ) ; ifmedia_add ( & ha -> media , ( IFM_ETHER | IFM_AUTO ) , 0 , NULL ) ; ifmedia_set ( & ha -> media , ( IFM_ETHER | IFM_AUTO ) ) ; QL_DPRINT2 ( ( dev , " \n " , __func__ ) ) ; return ; }
Name: qls_init_ifnet
 Function: Creates the Network Device Interface and Registers it with the O.S
Name : qls_init_ifnet Function : Creates the Network Device Interface and Registers it with the O . S