FreeBSD/sys/dev/ixl/ixlvc.c
/*
** ixlv_vc_completion
**
** Asynchronous completion function for admin queue messages. Rather than busy
** wait, we fire off our requests and assume that no errors will be returned.
** This function handles the reply messages.
*/
ixlv_vc_completion
Asynchronous completion function for admin queue messages. Rather than busy
wait, we fire off our requests and assume that no errors will be returned.
This function handles the reply messages.
ixlv_vc_completion Asynchronous completion function for admin queue messages . Rather than busy wait we fire off our requests and assume that no errors will be returned . This function handles the reply messages .
void
ixlv_vc_completion(struct ixlv_sc *sc,
    enum i40e_virtchnl_ops v_opcode,
    i40e_status v_retval, u8 *msg, u16 msglen)
{
	device_t	dev = sc->dev;
	struct ixl_vsi	*vsi = &sc->vsi;
	if (v_opcode == I40E_VIRTCHNL_OP_EVENT) {
		struct i40e_virtchnl_pf_event *vpe =
			(struct i40e_virtchnl_pf_event *)msg;
		switch (vpe->event) {
		case I40E_VIRTCHNL_EVENT_LINK_CHANGE:
#ifdef IXL_DEBUG
			device_printf(dev, "Link change: status %d, speed %d\n",
			    vpe->event_data.link_event.link_status,
			    vpe->event_data.link_event.link_speed);
#endif
			sc->link_up =
				vpe->event_data.link_event.link_status;
			sc->link_speed =
				vpe->event_data.link_event.link_speed;
			ixlv_update_link_status(sc);
			break;
		case I40E_VIRTCHNL_EVENT_RESET_IMPENDING:
			device_printf(dev, "PF initiated reset!\n");
			sc->init_state = IXLV_RESET_PENDING;
			mtx_unlock(&sc->mtx);
			ixlv_init(vsi);
			mtx_lock(&sc->mtx);
			break;
		default:
			device_printf(dev, "%s: Unknown event %d from AQ\n",
				__func__, vpe->event);
			break;
		}
		return;
	}
	if (v_retval) {
		device_printf(dev,
		    "%s: AQ returned error %d to our request %d!\n",
		    __func__, v_retval, v_opcode);
	}
#ifdef IXL_DEBUG
	if (v_opcode != I40E_VIRTCHNL_OP_GET_STATS)
		DDPRINTF(dev, "opcode %d", v_opcode);
#endif
	switch (v_opcode) {
	case I40E_VIRTCHNL_OP_GET_STATS:
		ixlv_update_stats_counters(sc, (struct i40e_eth_stats *)msg);
		break;
	case I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_ADD_MAC_FILTER,
		    v_retval);
		if (v_retval) {
			device_printf(dev, "WARNING: Error adding VF mac filter!\n");
			device_printf(dev, "WARNING: Device may not receive traffic!\n");
		}
		break;
	case I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_DEL_MAC_FILTER,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_CONFIGURE_PROMISC,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_ADD_VLAN:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_ADD_VLAN_FILTER,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_DEL_VLAN:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_DEL_VLAN_FILTER,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_ENABLE_QUEUES:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_ENABLE_QUEUES,
		    v_retval);
		if (v_retval == 0) {
			ixlv_update_link_status(sc);
			ixlv_enable_intr(vsi);
			vsi->ifp->if_drv_flags |= IFF_DRV_RUNNING;
		}
		break;
	case I40E_VIRTCHNL_OP_DISABLE_QUEUES:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_DISABLE_QUEUES,
		    v_retval);
		if (v_retval == 0) {
			ixlv_disable_intr(vsi);
			vsi->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING);
		}
		break;
	case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_CONFIGURE_QUEUES,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_MAP_VECTORS,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_CONFIG_RSS_KEY:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_CONFIG_RSS_KEY,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_SET_RSS_HENA:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_SET_RSS_HENA,
		    v_retval);
		break;
	case I40E_VIRTCHNL_OP_CONFIG_RSS_LUT:
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_CONFIG_RSS_LUT,
		    v_retval);
		break;
	default:
#ifdef IXL_DEBUG
		device_printf(dev,
		    "%s: Received unexpected message %d from PF.\n",
		    __func__, v_opcode);
#endif
		break;
	}
	return;
}
void ixlv_vc_completion ( struct ixlv_sc * sc , enum i40e_virtchnl_ops v_opcode , i40e_status v_retval , u8 * msg , u16 msglen ) { device_t dev = sc -> dev ; struct ixl_vsi * vsi = & sc -> vsi ; if ( v_opcode == I40E_VIRTCHNL_OP_EVENT ) { struct i40e_virtchnl_pf_event * vpe = ( struct i40e_virtchnl_pf_event * ) msg ; switch ( vpe -> event ) { case I40E_VIRTCHNL_EVENT_LINK_CHANGE : #ifdef IXL_DEBUG device_printf ( dev , " \n " , vpe -> event_data . link_event . link_status , vpe -> event_data . link_event . link_speed ) ; #endif sc -> link_up = vpe -> event_data . link_event . link_status ; sc -> link_speed = vpe -> event_data . link_event . link_speed ; ixlv_update_link_status ( sc ) ; break ; case I40E_VIRTCHNL_EVENT_RESET_IMPENDING : device_printf ( dev , " \n " ) ; sc -> init_state = IXLV_RESET_PENDING ; mtx_unlock ( & sc -> mtx ) ; ixlv_init ( vsi ) ; mtx_lock ( & sc -> mtx ) ; break ; default : device_printf ( dev , " \n " , __func__ , vpe -> event ) ; break ; } return ; } if ( v_retval ) { device_printf ( dev , " \n " , __func__ , v_retval , v_opcode ) ; } #ifdef IXL_DEBUG if ( v_opcode != I40E_VIRTCHNL_OP_GET_STATS ) DDPRINTF ( dev , " " , v_opcode ) ; #endif switch ( v_opcode ) { case I40E_VIRTCHNL_OP_GET_STATS : ixlv_update_stats_counters ( sc , ( struct i40e_eth_stats * ) msg ) ; break ; case I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_ADD_MAC_FILTER , v_retval ) ; if ( v_retval ) { device_printf ( dev , " \n " ) ; device_printf ( dev , " \n " ) ; } break ; case I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_DEL_MAC_FILTER , v_retval ) ; break ; case I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_CONFIGURE_PROMISC , v_retval ) ; break ; case I40E_VIRTCHNL_OP_ADD_VLAN : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_ADD_VLAN_FILTER , v_retval ) ; break ; case I40E_VIRTCHNL_OP_DEL_VLAN : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_DEL_VLAN_FILTER , v_retval ) ; break ; case I40E_VIRTCHNL_OP_ENABLE_QUEUES : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_ENABLE_QUEUES , v_retval ) ; if ( v_retval == 0 ) { ixlv_update_link_status ( sc ) ; ixlv_enable_intr ( vsi ) ; vsi -> ifp -> if_drv_flags |= IFF_DRV_RUNNING ; } break ; case I40E_VIRTCHNL_OP_DISABLE_QUEUES : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_DISABLE_QUEUES , v_retval ) ; if ( v_retval == 0 ) { ixlv_disable_intr ( vsi ) ; vsi -> ifp -> if_drv_flags &= ~ ( IFF_DRV_RUNNING ) ; } break ; case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_CONFIGURE_QUEUES , v_retval ) ; break ; case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_MAP_VECTORS , v_retval ) ; break ; case I40E_VIRTCHNL_OP_CONFIG_RSS_KEY : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_CONFIG_RSS_KEY , v_retval ) ; break ; case I40E_VIRTCHNL_OP_SET_RSS_HENA : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_SET_RSS_HENA , v_retval ) ; break ; case I40E_VIRTCHNL_OP_CONFIG_RSS_LUT : ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_CONFIG_RSS_LUT , v_retval ) ; break ; default : #ifdef IXL_DEBUG device_printf ( dev , " \n " , __func__ , v_opcode ) ; #endif break ; } return ; }
ixlv_vc_completion
Asynchronous completion function for admin queue messages.
ixlv_vc_completion Asynchronous completion function for admin queue messages .
/* Catch-all error response */ /* Update link status */ /* Turn on all interrupts */ /* And inform the stack we're ready */ /* TODO: Clear a state flag, so we know we're ready to run init again */ /* Turn off all interrupts */ /* Tell the stack that the interface is no longer active */