Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ixgbe/if_sriov.c
Show All 27 Lines | /****************************************************************************** | ||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
POSSIBILITY OF SUCH DAMAGE. | POSSIBILITY OF SUCH DAMAGE. | ||||
******************************************************************************/ | ******************************************************************************/ | ||||
/*$FreeBSD$*/ | /*$FreeBSD$*/ | ||||
#include "ixgbe.h" | #include "ixgbe.h" | ||||
#include "ixgbe_sriov.h" | |||||
#ifdef PCI_IOV | #ifdef PCI_IOV | ||||
MALLOC_DEFINE(M_IXGBE_SRIOV, "ix_sriov", "ix SR-IOV allocations"); | MALLOC_DEFINE(M_IXGBE_SRIOV, "ix_sriov", "ix SR-IOV allocations"); | ||||
/************************************************************************ | /************************************************************************ | ||||
* ixgbe_pci_iov_detach | * ixgbe_pci_iov_detach | ||||
************************************************************************/ | ************************************************************************/ | ||||
Show All 31 Lines | |||||
* ixgbe_align_all_queue_indices | * ixgbe_align_all_queue_indices | ||||
************************************************************************/ | ************************************************************************/ | ||||
inline void | inline void | ||||
ixgbe_align_all_queue_indices(struct adapter *adapter) | ixgbe_align_all_queue_indices(struct adapter *adapter) | ||||
{ | { | ||||
int i; | int i; | ||||
int index; | int index; | ||||
for (i = 0; i < adapter->num_queues; i++) { | for (i = 0; i < adapter->num_rx_queues; i++) { | ||||
index = ixgbe_vf_que_index(adapter->iov_mode, adapter->pool, i); | index = ixgbe_vf_que_index(adapter->iov_mode, adapter->pool, i); | ||||
adapter->rx_rings[i].me = index; | adapter->rx_queues[i].rxr.me = index; | ||||
adapter->tx_rings[i].me = index; | |||||
} | } | ||||
for (i = 0; i < adapter->num_tx_queues; i++) { | |||||
index = ixgbe_vf_que_index(adapter->iov_mode, adapter->pool, i); | |||||
adapter->tx_queues[i].txr.me = index; | |||||
} | } | ||||
} | |||||
/* Support functions for SR-IOV/VF management */ | /* Support functions for SR-IOV/VF management */ | ||||
static inline void | static inline void | ||||
ixgbe_send_vf_msg(struct adapter *adapter, struct ixgbe_vf *vf, u32 msg) | ixgbe_send_vf_msg(struct adapter *adapter, struct ixgbe_vf *vf, u32 msg) | ||||
{ | { | ||||
if (vf->flags & IXGBE_VF_CTS) | if (vf->flags & IXGBE_VF_CTS) | ||||
msg |= IXGBE_VT_MSGTYPE_CTS; | msg |= IXGBE_VT_MSGTYPE_CTS; | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | ixgbe_vf_set_default_vlan(struct adapter *adapter, struct ixgbe_vf *vf, | ||||
/* Disable Multicast Promicuous Mode. */ | /* Disable Multicast Promicuous Mode. */ | ||||
vmolr &= ~IXGBE_VMOLR_MPE; | vmolr &= ~IXGBE_VMOLR_MPE; | ||||
/* Accept broadcasts. */ | /* Accept broadcasts. */ | ||||
vmolr |= IXGBE_VMOLR_BAM; | vmolr |= IXGBE_VMOLR_BAM; | ||||
if (tag == 0) { | if (tag == 0) { | ||||
/* Accept non-vlan tagged traffic. */ | /* Accept non-vlan tagged traffic. */ | ||||
//vmolr |= IXGBE_VMOLR_AUPE; | vmolr |= IXGBE_VMOLR_AUPE; | ||||
/* Allow VM to tag outgoing traffic; no default tag. */ | /* Allow VM to tag outgoing traffic; no default tag. */ | ||||
vmvir = 0; | vmvir = 0; | ||||
} else { | } else { | ||||
/* Require vlan-tagged traffic. */ | /* Require vlan-tagged traffic. */ | ||||
vmolr &= ~IXGBE_VMOLR_AUPE; | vmolr &= ~IXGBE_VMOLR_AUPE; | ||||
/* Tag all traffic with provided vlan tag. */ | /* Tag all traffic with provided vlan tag. */ | ||||
Show All 19 Lines | ixgbe_vf_frame_size_compatible(struct adapter *adapter, struct ixgbe_vf *vf) | ||||
switch (vf->api_ver) { | switch (vf->api_ver) { | ||||
case IXGBE_API_VER_1_0: | case IXGBE_API_VER_1_0: | ||||
case IXGBE_API_VER_UNKNOWN: | case IXGBE_API_VER_UNKNOWN: | ||||
/* | /* | ||||
* On legacy (1.0 and older) VF versions, we don't support jumbo | * On legacy (1.0 and older) VF versions, we don't support jumbo | ||||
* frames on either the PF or the VF. | * frames on either the PF or the VF. | ||||
*/ | */ | ||||
if (adapter->max_frame_size > ETHER_MAX_LEN || | if (adapter->max_frame_size > ETHER_MAX_LEN || | ||||
vf->max_frame_size > ETHER_MAX_LEN) | vf->maximum_frame_size > ETHER_MAX_LEN) | ||||
return (FALSE); | return (FALSE); | ||||
return (TRUE); | return (TRUE); | ||||
break; | break; | ||||
case IXGBE_API_VER_1_1: | case IXGBE_API_VER_1_1: | ||||
default: | default: | ||||
/* | /* | ||||
* 1.1 or later VF versions always work if they aren't using | * 1.1 or later VF versions always work if they aren't using | ||||
* jumbo frames. | * jumbo frames. | ||||
*/ | */ | ||||
if (vf->max_frame_size <= ETHER_MAX_LEN) | if (vf->maximum_frame_size <= ETHER_MAX_LEN) | ||||
return (TRUE); | return (TRUE); | ||||
/* | /* | ||||
* Jumbo frames only work with VFs if the PF is also using jumbo | * Jumbo frames only work with VFs if the PF is also using jumbo | ||||
* frames. | * frames. | ||||
*/ | */ | ||||
if (adapter->max_frame_size <= ETHER_MAX_LEN) | if (adapter->max_frame_size <= ETHER_MAX_LEN) | ||||
return (TRUE); | return (TRUE); | ||||
return (FALSE); | return (FALSE); | ||||
} | } | ||||
} /* ixgbe_vf_frame_size_compatible */ | } /* ixgbe_vf_frame_size_compatible */ | ||||
static void | static void | ||||
ixgbe_process_vf_reset(struct adapter *adapter, struct ixgbe_vf *vf) | ixgbe_process_vf_reset(struct adapter *adapter, struct ixgbe_vf *vf) | ||||
{ | { | ||||
ixgbe_vf_set_default_vlan(adapter, vf, vf->default_vlan); | ixgbe_vf_set_default_vlan(adapter, vf, vf->default_vlan); | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | ixgbe_vf_set_vlan(struct adapter *adapter, struct ixgbe_vf *vf, uint32_t *msg) | ||||
tag = msg[1] & IXGBE_VLVF_VLANID_MASK; | tag = msg[1] & IXGBE_VLVF_VLANID_MASK; | ||||
if (!(vf->flags & IXGBE_VF_CAP_VLAN)) { | if (!(vf->flags & IXGBE_VF_CAP_VLAN)) { | ||||
ixgbe_send_vf_nack(adapter, vf, msg[0]); | ixgbe_send_vf_nack(adapter, vf, msg[0]); | ||||
return; | return; | ||||
} | } | ||||
/* It is illegal to enable vlan tag 0. */ | /* It is illegal to enable vlan tag 0. */ | ||||
if (tag == 0 && enable != 0){ | if (tag == 0 && enable != 0) { | ||||
ixgbe_send_vf_nack(adapter, vf, msg[0]); | ixgbe_send_vf_nack(adapter, vf, msg[0]); | ||||
return; | return; | ||||
} | } | ||||
ixgbe_set_vfta(hw, tag, vf->pool, enable, false); | ixgbe_set_vfta(hw, tag, vf->pool, enable, false); | ||||
ixgbe_send_vf_ack(adapter, vf, msg[0]); | ixgbe_send_vf_ack(adapter, vf, msg[0]); | ||||
} /* ixgbe_vf_set_vlan */ | } /* ixgbe_vf_set_vlan */ | ||||
Show All 16 Lines | ixgbe_vf_set_lpe(struct adapter *adapter, struct ixgbe_vf *vf, uint32_t *msg) | ||||
vf_max_size -= ETHER_CRC_LEN; | vf_max_size -= ETHER_CRC_LEN; | ||||
if (vf_max_size > IXGBE_MAX_FRAME_SIZE) { | if (vf_max_size > IXGBE_MAX_FRAME_SIZE) { | ||||
/* We intentionally ACK invalid LPE requests. */ | /* We intentionally ACK invalid LPE requests. */ | ||||
ixgbe_send_vf_ack(adapter, vf, msg[0]); | ixgbe_send_vf_ack(adapter, vf, msg[0]); | ||||
return; | return; | ||||
} | } | ||||
vf->max_frame_size = vf_max_size; | vf->maximum_frame_size = vf_max_size; | ||||
ixgbe_update_max_frame(adapter, vf->max_frame_size); | ixgbe_update_max_frame(adapter, vf->maximum_frame_size); | ||||
/* | /* | ||||
* We might have to disable reception to this VF if the frame size is | * We might have to disable reception to this VF if the frame size is | ||||
* not compatible with the config on the PF. | * not compatible with the config on the PF. | ||||
*/ | */ | ||||
ixgbe_vf_enable_receive(adapter, vf); | ixgbe_vf_enable_receive(adapter, vf); | ||||
mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); | mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | ixgbe_vf_get_queues(struct adapter *adapter, struct ixgbe_vf *vf, uint32_t *msg) | ||||
resp[IXGBE_VF_TRANS_VLAN] = (vf->default_vlan != 0); | resp[IXGBE_VF_TRANS_VLAN] = (vf->default_vlan != 0); | ||||
resp[IXGBE_VF_DEF_QUEUE] = 0; | resp[IXGBE_VF_DEF_QUEUE] = 0; | ||||
hw->mbx.ops.write(hw, resp, IXGBE_VF_GET_QUEUES_RESP_LEN, vf->pool); | hw->mbx.ops.write(hw, resp, IXGBE_VF_GET_QUEUES_RESP_LEN, vf->pool); | ||||
} /* ixgbe_vf_get_queues */ | } /* ixgbe_vf_get_queues */ | ||||
static void | static void | ||||
ixgbe_process_vf_msg(struct adapter *adapter, struct ixgbe_vf *vf) | ixgbe_process_vf_msg(if_ctx_t ctx, struct ixgbe_vf *vf) | ||||
{ | { | ||||
struct adapter *adapter = iflib_get_softc(ctx); | |||||
#ifdef KTR | |||||
struct ifnet *ifp = iflib_get_ifp(ctx); | |||||
#endif | |||||
struct ixgbe_hw *hw; | struct ixgbe_hw *hw; | ||||
uint32_t msg[IXGBE_VFMAILBOX_SIZE]; | uint32_t msg[IXGBE_VFMAILBOX_SIZE]; | ||||
int error; | int error; | ||||
hw = &adapter->hw; | hw = &adapter->hw; | ||||
error = hw->mbx.ops.read(hw, msg, IXGBE_VFMAILBOX_SIZE, vf->pool); | error = hw->mbx.ops.read(hw, msg, IXGBE_VFMAILBOX_SIZE, vf->pool); | ||||
if (error != 0) | if (error != 0) | ||||
return; | return; | ||||
CTR3(KTR_MALLOC, "%s: received msg %x from %d", | CTR3(KTR_MALLOC, "%s: received msg %x from %d", ifp->if_xname, | ||||
adapter->ifp->if_xname, msg[0], vf->pool); | msg[0], vf->pool); | ||||
if (msg[0] == IXGBE_VF_RESET) { | if (msg[0] == IXGBE_VF_RESET) { | ||||
ixgbe_vf_reset_msg(adapter, vf, msg); | ixgbe_vf_reset_msg(adapter, vf, msg); | ||||
return; | return; | ||||
} | } | ||||
if (!(vf->flags & IXGBE_VF_CTS)) { | if (!(vf->flags & IXGBE_VF_CTS)) { | ||||
ixgbe_send_vf_nack(adapter, vf, msg[0]); | ixgbe_send_vf_nack(adapter, vf, msg[0]); | ||||
return; | return; | ||||
Show All 24 Lines | #endif | ||||
default: | default: | ||||
ixgbe_send_vf_nack(adapter, vf, msg[0]); | ixgbe_send_vf_nack(adapter, vf, msg[0]); | ||||
} | } | ||||
} /* ixgbe_process_vf_msg */ | } /* ixgbe_process_vf_msg */ | ||||
/* Tasklet for handling VF -> PF mailbox messages */ | /* Tasklet for handling VF -> PF mailbox messages */ | ||||
void | void | ||||
ixgbe_handle_mbx(void *context, int pending) | ixgbe_handle_mbx(void *context) | ||||
{ | { | ||||
struct adapter *adapter; | if_ctx_t ctx = context; | ||||
struct adapter *adapter = iflib_get_softc(ctx); | |||||
struct ixgbe_hw *hw; | struct ixgbe_hw *hw; | ||||
struct ixgbe_vf *vf; | struct ixgbe_vf *vf; | ||||
int i; | int i; | ||||
adapter = context; | |||||
hw = &adapter->hw; | hw = &adapter->hw; | ||||
IXGBE_CORE_LOCK(adapter); | |||||
for (i = 0; i < adapter->num_vfs; i++) { | for (i = 0; i < adapter->num_vfs; i++) { | ||||
vf = &adapter->vfs[i]; | vf = &adapter->vfs[i]; | ||||
if (vf->flags & IXGBE_VF_ACTIVE) { | if (vf->flags & IXGBE_VF_ACTIVE) { | ||||
if (hw->mbx.ops.check_for_rst(hw, vf->pool) == 0) | if (hw->mbx.ops.check_for_rst(hw, vf->pool) == 0) | ||||
ixgbe_process_vf_reset(adapter, vf); | ixgbe_process_vf_reset(adapter, vf); | ||||
if (hw->mbx.ops.check_for_msg(hw, vf->pool) == 0) | if (hw->mbx.ops.check_for_msg(hw, vf->pool) == 0) | ||||
ixgbe_process_vf_msg(adapter, vf); | ixgbe_process_vf_msg(ctx, vf); | ||||
if (hw->mbx.ops.check_for_ack(hw, vf->pool) == 0) | if (hw->mbx.ops.check_for_ack(hw, vf->pool) == 0) | ||||
ixgbe_process_vf_ack(adapter, vf); | ixgbe_process_vf_ack(adapter, vf); | ||||
} | } | ||||
} | } | ||||
IXGBE_CORE_UNLOCK(adapter); | |||||
} /* ixgbe_handle_mbx */ | } /* ixgbe_handle_mbx */ | ||||
int | int | ||||
ixgbe_init_iov(device_t dev, u16 num_vfs, const nvlist_t *config) | ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) | ||||
{ | { | ||||
struct adapter *adapter; | struct adapter *adapter; | ||||
int retval = 0; | int retval = 0; | ||||
adapter = device_get_softc(dev); | adapter = iflib_get_softc(ctx); | ||||
adapter->iov_mode = IXGBE_NO_VM; | adapter->iov_mode = IXGBE_NO_VM; | ||||
if (num_vfs == 0) { | if (num_vfs == 0) { | ||||
/* Would we ever get num_vfs = 0? */ | /* Would we ever get num_vfs = 0? */ | ||||
retval = EINVAL; | retval = EINVAL; | ||||
goto err_init_iov; | goto err_init_iov; | ||||
} | } | ||||
Show All 11 Lines | ixgbe_if_iov_init(if_ctx_t ctx, u16 num_vfs, const nvlist_t *config) | ||||
/* Again, reserving 1 VM's worth of queues for the PF */ | /* Again, reserving 1 VM's worth of queues for the PF */ | ||||
adapter->pool = adapter->iov_mode - 1; | adapter->pool = adapter->iov_mode - 1; | ||||
if ((num_vfs > adapter->pool) || (num_vfs >= IXGBE_64_VM)) { | if ((num_vfs > adapter->pool) || (num_vfs >= IXGBE_64_VM)) { | ||||
retval = ENOSPC; | retval = ENOSPC; | ||||
goto err_init_iov; | goto err_init_iov; | ||||
} | } | ||||
IXGBE_CORE_LOCK(adapter); | |||||
adapter->vfs = malloc(sizeof(*adapter->vfs) * num_vfs, M_IXGBE_SRIOV, | adapter->vfs = malloc(sizeof(*adapter->vfs) * num_vfs, M_IXGBE_SRIOV, | ||||
M_NOWAIT | M_ZERO); | M_NOWAIT | M_ZERO); | ||||
if (adapter->vfs == NULL) { | if (adapter->vfs == NULL) { | ||||
retval = ENOMEM; | retval = ENOMEM; | ||||
IXGBE_CORE_UNLOCK(adapter); | |||||
goto err_init_iov; | goto err_init_iov; | ||||
} | } | ||||
adapter->num_vfs = num_vfs; | adapter->num_vfs = num_vfs; | ||||
adapter->init_locked(adapter); | ixgbe_if_init(adapter->ctx); | ||||
adapter->feat_en |= IXGBE_FEATURE_SRIOV; | adapter->feat_en |= IXGBE_FEATURE_SRIOV; | ||||
IXGBE_CORE_UNLOCK(adapter); | return (retval); | ||||
return retval; | |||||
err_init_iov: | err_init_iov: | ||||
adapter->num_vfs = 0; | adapter->num_vfs = 0; | ||||
adapter->pool = 0; | adapter->pool = 0; | ||||
adapter->iov_mode = IXGBE_NO_VM; | adapter->iov_mode = IXGBE_NO_VM; | ||||
return retval; | return (retval); | ||||
} /* ixgbe_init_iov */ | } /* ixgbe_if_iov_init */ | ||||
void | void | ||||
ixgbe_uninit_iov(device_t dev) | ixgbe_if_iov_uninit(if_ctx_t ctx) | ||||
{ | { | ||||
struct ixgbe_hw *hw; | struct ixgbe_hw *hw; | ||||
struct adapter *adapter; | struct adapter *adapter; | ||||
uint32_t pf_reg, vf_reg; | uint32_t pf_reg, vf_reg; | ||||
adapter = device_get_softc(dev); | adapter = iflib_get_softc(ctx); | ||||
hw = &adapter->hw; | hw = &adapter->hw; | ||||
IXGBE_CORE_LOCK(adapter); | |||||
/* Enable rx/tx for the PF and disable it for all VFs. */ | /* Enable rx/tx for the PF and disable it for all VFs. */ | ||||
pf_reg = IXGBE_VF_INDEX(adapter->pool); | pf_reg = IXGBE_VF_INDEX(adapter->pool); | ||||
IXGBE_WRITE_REG(hw, IXGBE_VFRE(pf_reg), IXGBE_VF_BIT(adapter->pool)); | IXGBE_WRITE_REG(hw, IXGBE_VFRE(pf_reg), IXGBE_VF_BIT(adapter->pool)); | ||||
IXGBE_WRITE_REG(hw, IXGBE_VFTE(pf_reg), IXGBE_VF_BIT(adapter->pool)); | IXGBE_WRITE_REG(hw, IXGBE_VFTE(pf_reg), IXGBE_VF_BIT(adapter->pool)); | ||||
if (pf_reg == 0) | if (pf_reg == 0) | ||||
vf_reg = 1; | vf_reg = 1; | ||||
else | else | ||||
vf_reg = 0; | vf_reg = 0; | ||||
IXGBE_WRITE_REG(hw, IXGBE_VFRE(vf_reg), 0); | IXGBE_WRITE_REG(hw, IXGBE_VFRE(vf_reg), 0); | ||||
IXGBE_WRITE_REG(hw, IXGBE_VFTE(vf_reg), 0); | IXGBE_WRITE_REG(hw, IXGBE_VFTE(vf_reg), 0); | ||||
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0); | IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0); | ||||
free(adapter->vfs, M_IXGBE_SRIOV); | free(adapter->vfs, M_IXGBE_SRIOV); | ||||
adapter->vfs = NULL; | adapter->vfs = NULL; | ||||
adapter->num_vfs = 0; | adapter->num_vfs = 0; | ||||
adapter->feat_en &= ~IXGBE_FEATURE_SRIOV; | adapter->feat_en &= ~IXGBE_FEATURE_SRIOV; | ||||
} /* ixgbe_if_iov_uninit */ | |||||
IXGBE_CORE_UNLOCK(adapter); | |||||
} /* ixgbe_uninit_iov */ | |||||
static void | static void | ||||
ixgbe_init_vf(struct adapter *adapter, struct ixgbe_vf *vf) | ixgbe_init_vf(struct adapter *adapter, struct ixgbe_vf *vf) | ||||
{ | { | ||||
struct ixgbe_hw *hw; | struct ixgbe_hw *hw; | ||||
uint32_t vf_index, pfmbimr; | uint32_t vf_index, pfmbimr; | ||||
IXGBE_CORE_LOCK_ASSERT(adapter); | |||||
hw = &adapter->hw; | hw = &adapter->hw; | ||||
if (!(vf->flags & IXGBE_VF_ACTIVE)) | if (!(vf->flags & IXGBE_VF_ACTIVE)) | ||||
return; | return; | ||||
vf_index = IXGBE_VF_INDEX(vf->pool); | vf_index = IXGBE_VF_INDEX(vf->pool); | ||||
pfmbimr = IXGBE_READ_REG(hw, IXGBE_PFMBIMR(vf_index)); | pfmbimr = IXGBE_READ_REG(hw, IXGBE_PFMBIMR(vf_index)); | ||||
pfmbimr |= IXGBE_VF_BIT(vf->pool); | pfmbimr |= IXGBE_VF_BIT(vf->pool); | ||||
Show All 19 Lines | |||||
{ | { | ||||
struct ixgbe_hw *hw = &adapter->hw; | struct ixgbe_hw *hw = &adapter->hw; | ||||
uint32_t mrqc, mtqc, vt_ctl, vf_reg, gcr_ext, gpie; | uint32_t mrqc, mtqc, vt_ctl, vf_reg, gcr_ext, gpie; | ||||
int i; | int i; | ||||
if (adapter->iov_mode == IXGBE_NO_VM) | if (adapter->iov_mode == IXGBE_NO_VM) | ||||
return; | return; | ||||
IXGBE_CORE_LOCK_ASSERT(adapter); | |||||
/* RMW appropriate registers based on IOV mode */ | /* RMW appropriate registers based on IOV mode */ | ||||
/* Read... */ | /* Read... */ | ||||
mrqc = IXGBE_READ_REG(hw, IXGBE_MRQC); | mrqc = IXGBE_READ_REG(hw, IXGBE_MRQC); | ||||
gcr_ext = IXGBE_READ_REG(hw, IXGBE_GCR_EXT); | gcr_ext = IXGBE_READ_REG(hw, IXGBE_GCR_EXT); | ||||
gpie = IXGBE_READ_REG(hw, IXGBE_GPIE); | gpie = IXGBE_READ_REG(hw, IXGBE_GPIE); | ||||
/* Modify... */ | /* Modify... */ | ||||
mrqc &= ~IXGBE_MRQC_MRQE_MASK; | mrqc &= ~IXGBE_MRQC_MRQE_MASK; | ||||
mtqc = IXGBE_MTQC_VT_ENA; /* No initial MTQC read needed */ | mtqc = IXGBE_MTQC_VT_ENA; /* No initial MTQC read needed */ | ||||
Show All 40 Lines | |||||
/* Check the max frame setting of all active VF's */ | /* Check the max frame setting of all active VF's */ | ||||
void | void | ||||
ixgbe_recalculate_max_frame(struct adapter *adapter) | ixgbe_recalculate_max_frame(struct adapter *adapter) | ||||
{ | { | ||||
struct ixgbe_vf *vf; | struct ixgbe_vf *vf; | ||||
IXGBE_CORE_LOCK_ASSERT(adapter); | |||||
for (int i = 0; i < adapter->num_vfs; i++) { | for (int i = 0; i < adapter->num_vfs; i++) { | ||||
vf = &adapter->vfs[i]; | vf = &adapter->vfs[i]; | ||||
if (vf->flags & IXGBE_VF_ACTIVE) | if (vf->flags & IXGBE_VF_ACTIVE) | ||||
ixgbe_update_max_frame(adapter, vf->max_frame_size); | ixgbe_update_max_frame(adapter, vf->maximum_frame_size); | ||||
} | } | ||||
} /* ixgbe_recalculate_max_frame */ | } /* ixgbe_recalculate_max_frame */ | ||||
int | int | ||||
ixgbe_add_vf(device_t dev, u16 vfnum, const nvlist_t *config) | ixgbe_if_iov_vf_add(if_ctx_t ctx, u16 vfnum, const nvlist_t *config) | ||||
{ | { | ||||
struct adapter *adapter; | struct adapter *adapter; | ||||
struct ixgbe_vf *vf; | struct ixgbe_vf *vf; | ||||
const void *mac; | const void *mac; | ||||
adapter = device_get_softc(dev); | adapter = iflib_get_softc(ctx); | ||||
KASSERT(vfnum < adapter->num_vfs, ("VF index %d is out of range %d", | KASSERT(vfnum < adapter->num_vfs, ("VF index %d is out of range %d", | ||||
vfnum, adapter->num_vfs)); | vfnum, adapter->num_vfs)); | ||||
IXGBE_CORE_LOCK(adapter); | |||||
vf = &adapter->vfs[vfnum]; | vf = &adapter->vfs[vfnum]; | ||||
vf->pool= vfnum; | vf->pool= vfnum; | ||||
/* RAR[0] is used by the PF so use vfnum + 1 for VF RAR. */ | /* RAR[0] is used by the PF so use vfnum + 1 for VF RAR. */ | ||||
vf->rar_index = vfnum + 1; | vf->rar_index = vfnum + 1; | ||||
vf->default_vlan = 0; | vf->default_vlan = 0; | ||||
vf->max_frame_size = ETHER_MAX_LEN; | vf->maximum_frame_size = ETHER_MAX_LEN; | ||||
ixgbe_update_max_frame(adapter, vf->max_frame_size); | ixgbe_update_max_frame(adapter, vf->maximum_frame_size); | ||||
if (nvlist_exists_binary(config, "mac-addr")) { | if (nvlist_exists_binary(config, "mac-addr")) { | ||||
mac = nvlist_get_binary(config, "mac-addr", NULL); | mac = nvlist_get_binary(config, "mac-addr", NULL); | ||||
bcopy(mac, vf->ether_addr, ETHER_ADDR_LEN); | bcopy(mac, vf->ether_addr, ETHER_ADDR_LEN); | ||||
if (nvlist_get_bool(config, "allow-set-mac")) | if (nvlist_get_bool(config, "allow-set-mac")) | ||||
vf->flags |= IXGBE_VF_CAP_MAC; | vf->flags |= IXGBE_VF_CAP_MAC; | ||||
} else | } else | ||||
/* | /* | ||||
* If the administrator has not specified a MAC address then | * If the administrator has not specified a MAC address then | ||||
* we must allow the VF to choose one. | * we must allow the VF to choose one. | ||||
*/ | */ | ||||
vf->flags |= IXGBE_VF_CAP_MAC; | vf->flags |= IXGBE_VF_CAP_MAC; | ||||
vf->flags |= IXGBE_VF_ACTIVE; | vf->flags |= IXGBE_VF_ACTIVE; | ||||
ixgbe_init_vf(adapter, vf); | ixgbe_init_vf(adapter, vf); | ||||
IXGBE_CORE_UNLOCK(adapter); | |||||
return (0); | return (0); | ||||
} /* ixgbe_add_vf */ | } /* ixgbe_if_iov_vf_add */ | ||||
#else | #else | ||||
void | void | ||||
ixgbe_handle_mbx(void *context, int pending) | ixgbe_handle_mbx(void *context) | ||||
{ | { | ||||
UNREFERENCED_2PARAMETER(context, pending); | UNREFERENCED_PARAMETER(context); | ||||
} /* ixgbe_handle_mbx */ | } /* ixgbe_handle_mbx */ | ||||
inline int | |||||
ixgbe_vf_que_index(int mode, int vfnum, int num) | |||||
{ | |||||
UNREFERENCED_2PARAMETER(mode, vfnum); | |||||
return num; | |||||
} /* ixgbe_vf_que_index */ | |||||
#endif | #endif |