FreeBSD/sys/dev/ixl/ixl_pf_main.c
/*********************************************************************
 *  Init entry point
 *
 *  This routine is used in two ways. It is used by the stack as
 *  init entry point in network interface structure. It is also used
 *  by the driver as a hw/sw initialization routine to get to a
 *  consistent state.
 *
 *  return 0 on success, positive on failure
 **********************************************************************/
Init entry point
This routine is used in two ways. It is used by the stack as
init entry point in network interface structure. It is also used
by the driver as a hw/sw initialization routine to get to a
consistent state.

return 0 on success, positive on failure
Init entry point This routine is used in two ways . It is used by the stack as init entry point in network interface structure . It is also used by the driver as a hw / sw initialization routine to get to a consistent state . return 0 on success positive on failure
void
ixl_init_locked(struct ixl_pf *pf)
{
	struct i40e_hw	*hw = &pf->hw;
	struct ixl_vsi	*vsi = &pf->vsi;
	struct ifnet	*ifp = vsi->ifp;
	device_t 	dev = pf->dev;
	struct i40e_filter_control_settings	filter;
	u8		tmpaddr[ETHER_ADDR_LEN];
	int		ret;
	mtx_assert(&pf->pf_mtx, MA_OWNED);
	INIT_DEBUGOUT("ixl_init_locked: begin");
	ixl_stop_locked(pf);
	bcopy(IF_LLADDR(vsi->ifp), tmpaddr,
	      I40E_ETH_LENGTH_OF_ADDRESS);
	if (!cmp_etheraddr(hw->mac.addr, tmpaddr) &&
	    (i40e_validate_mac_addr(tmpaddr) == I40E_SUCCESS)) {
		ixl_del_filter(vsi, hw->mac.addr, IXL_VLAN_ANY);
		bcopy(tmpaddr, hw->mac.addr,
		    I40E_ETH_LENGTH_OF_ADDRESS);
		ret = i40e_aq_mac_address_write(hw,
		    I40E_AQC_WRITE_TYPE_LAA_ONLY,
		    hw->mac.addr, NULL);
		if (ret) {
			device_printf(dev, "LLA address"
			 "change failed!!\n");
			return;
		}
	}
	ixl_add_filter(vsi, hw->mac.addr, IXL_VLAN_ANY);
	ifp->if_hwassist = 0;
	if (ifp->if_capenable & IFCAP_TSO)
		ifp->if_hwassist |= CSUM_TSO;
	if (ifp->if_capenable & IFCAP_TXCSUM)
		ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
	if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
		ifp->if_hwassist |= (CSUM_TCP_IPV6 | CSUM_UDP_IPV6);
	bzero(&filter, sizeof(filter));
	filter.enable_ethtype = TRUE;
	filter.enable_macvlan = TRUE;
	filter.enable_fdir = FALSE;
	filter.hash_lut_size = I40E_HASH_LUT_SIZE_512;
	if (i40e_set_filter_control(hw, &filter))
		device_printf(dev, "i40e_set_filter_control() failed\n");
	if (ixl_initialize_vsi(vsi)) {
		device_printf(dev, "initialize vsi failed!!\n");
		return;
	}
	ixl_config_rss(pf);
	ixl_init_filters(vsi);
	ixl_setup_vlan_filters(vsi);
	if (pf->enable_msix) {
		ixl_configure_queue_intr_msix(pf);
		ixl_configure_itr(pf);
	} else
		ixl_configure_legacy(pf);
	ixl_enable_rings(vsi);
	i40e_aq_set_default_vsi(hw, vsi->seid, NULL);
	ixl_reconfigure_filters(vsi);
	ixl_enable_intr(vsi);
	hw->phy.get_link_info = TRUE;
	i40e_get_link_status(hw, &pf->link_up);
	ixl_update_link_status(pf);
	ixl_get_initial_advertised_speeds(pf);
	callout_reset(&pf->timer, hz, ixl_local_timer, pf);
	ifp->if_drv_flags |= IFF_DRV_RUNNING;
}
void ixl_init_locked ( struct ixl_pf * pf ) { struct i40e_hw * hw = & pf -> hw ; struct ixl_vsi * vsi = & pf -> vsi ; struct ifnet * ifp = vsi -> ifp ; device_t dev = pf -> dev ; struct i40e_filter_control_settings filter ; u8 tmpaddr [ ETHER_ADDR_LEN ] ; int ret ; mtx_assert ( & pf -> pf_mtx , MA_OWNED ) ; INIT_DEBUGOUT ( " " ) ; ixl_stop_locked ( pf ) ; bcopy ( IF_LLADDR ( vsi -> ifp ) , tmpaddr , I40E_ETH_LENGTH_OF_ADDRESS ) ; if ( ! cmp_etheraddr ( hw -> mac . addr , tmpaddr ) && ( i40e_validate_mac_addr ( tmpaddr ) == I40E_SUCCESS ) ) { ixl_del_filter ( vsi , hw -> mac . addr , IXL_VLAN_ANY ) ; bcopy ( tmpaddr , hw -> mac . addr , I40E_ETH_LENGTH_OF_ADDRESS ) ; ret = i40e_aq_mac_address_write ( hw , I40E_AQC_WRITE_TYPE_LAA_ONLY , hw -> mac . addr , NULL ) ; if ( ret ) { device_printf ( dev , " " " \n " ) ; return ; } } ixl_add_filter ( vsi , hw -> mac . addr , IXL_VLAN_ANY ) ; ifp -> if_hwassist = 0 ; if ( ifp -> if_capenable & IFCAP_TSO ) ifp -> if_hwassist |= CSUM_TSO ; if ( ifp -> if_capenable & IFCAP_TXCSUM ) ifp -> if_hwassist |= ( CSUM_TCP | CSUM_UDP ) ; if ( ifp -> if_capenable & IFCAP_TXCSUM_IPV6 ) ifp -> if_hwassist |= ( CSUM_TCP_IPV6 | CSUM_UDP_IPV6 ) ; bzero ( & filter , sizeof ( filter ) ) ; filter . enable_ethtype = TRUE ; filter . enable_macvlan = TRUE ; filter . enable_fdir = FALSE ; filter . hash_lut_size = I40E_HASH_LUT_SIZE_512 ; if ( i40e_set_filter_control ( hw , & filter ) ) device_printf ( dev , " \n " ) ; if ( ixl_initialize_vsi ( vsi ) ) { device_printf ( dev , " \n " ) ; return ; } ixl_config_rss ( pf ) ; ixl_init_filters ( vsi ) ; ixl_setup_vlan_filters ( vsi ) ; if ( pf -> enable_msix ) { ixl_configure_queue_intr_msix ( pf ) ; ixl_configure_itr ( pf ) ; } else ixl_configure_legacy ( pf ) ; ixl_enable_rings ( vsi ) ; i40e_aq_set_default_vsi ( hw , vsi -> seid , NULL ) ; ixl_reconfigure_filters ( vsi ) ; ixl_enable_intr ( vsi ) ; hw -> phy . get_link_info = TRUE ; i40e_get_link_status ( hw , & pf -> link_up ) ; ixl_update_link_status ( pf ) ; ixl_get_initial_advertised_speeds ( pf ) ; callout_reset ( & pf -> timer , hz , ixl_local_timer , pf ) ; ifp -> if_drv_flags |= IFF_DRV_RUNNING ; }
Init entry point
  This routine is used in two ways.
Init entry point This routine is used in two ways .
/* Get the latest mac address... User might use a LAA */ /* Set the various hardware offload abilities */ /* Set up the device filtering */ /* Prepare the VSI: rings, hmc contexts, etc... */ /* Set up RSS */ /* Add protocol filters to list */ /* Setup vlan's if needed */ /* Set up MSI/X routing and the ITR settings */ /* And now turn on interrupts */ /* Get link info */ /* Set initial advertised speed sysctl value */ /* Start the local timer */ /* Now inform the stack we're ready */