#define AVF_MBOX_BUF_SZ 512
#define AVF_RXQ_SZ 512
#define AVF_TXQ_SZ 512
-#define AVF_ITR_INT 8160
+#define AVF_ITR_INT 32
#define PCI_VENDOR_ID_INTEL 0x8086
#define PCI_DEVICE_ID_INTEL_AVF 0x1889
{
clib_error_t *err = 0;
avf_aq_desc_t *d, dc;
- f64 t0, wait_time, suspend_time = AVF_AQ_ENQ_SUSPEND_TIME;
+ f64 t0, suspend_time = AVF_AQ_ENQ_SUSPEND_TIME;
d = &ad->atq[ad->atq_next_slot];
clib_memcpy_fast (d, dt, sizeof (avf_aq_desc_t));
t0 = vlib_time_now (vm);
retry:
vlib_process_suspend (vm, suspend_time);
- wait_time = vlib_time_now (vm) - t0;
if (((d->flags & AVF_AQ_F_DD) == 0) || ((d->flags & AVF_AQ_F_CMP) == 0))
{
- if (wait_time > AVF_AQ_ENQ_MAX_WAIT_TIME)
+ f64 t = vlib_time_now (vm) - t0;
+ if (t > AVF_AQ_ENQ_MAX_WAIT_TIME)
{
+ avf_log_err (ad, "aq_desc_enq failed (timeout %.3fs)", t);
err = clib_error_return (0, "adminq enqueue timeout [opcode 0x%x]",
d->opcode);
goto done;
clib_error_t *err;
avf_aq_desc_t *d, dt = {.opcode = 0x801,.v_opcode = op };
u32 head;
- int n_retry = 5;
-
+ f64 t0, suspend_time = AVF_SEND_TO_PF_SUSPEND_TIME;
/* suppress interrupt in the next adminq receive slot
as we are going to wait for response
if ((err = avf_aq_desc_enq (vm, ad, &dt, in, in_len)))
return err;
+ t0 = vlib_time_now (vm);
retry:
head = avf_get_u32 (ad->bar0, AVF_ARQH);
if (ad->arq_next_slot == head)
{
- if (--n_retry == 0)
- return clib_error_return (0, "timeout");
- vlib_process_suspend (vm, 10e-3);
+ f64 t = vlib_time_now (vm) - t0;
+ if (t > AVF_SEND_TO_PF_MAX_WAIT_TIME)
+ {
+ avf_log_err (ad, "send_to_pf failed (timeout %.3fs)", t);
+ return clib_error_return (0, "timeout");
+ }
+ vlib_process_suspend (vm, suspend_time);
+ suspend_time *= 2;
goto retry;
}
clib_memcpy_fast (e, buf, sizeof (virtchnl_pf_event_t));
avf_arq_slot_init (ad, ad->arq_next_slot);
ad->arq_next_slot++;
- n_retry = 5;
+ /* reset timer */
+ t0 = vlib_time_now (vm);
+ suspend_time = AVF_SEND_TO_PF_SUSPEND_TIME;
goto retry;
}
for (i = 0; i < ad->rss_lut_size; i++)
rl->lut[i] = i % ad->n_rx_queues;
- avf_log_debug (ad, "config_rss_lut: vsi_id %u rss_lut_size %u lut %U",
- rl->vsi_id, rl->lut_entries, format_hex_bytes, rl->lut,
- rl->lut_entries);
+ avf_log_debug (ad, "config_rss_lut: vsi_id %u rss_lut_size %u lut 0x%U",
+ rl->vsi_id, rl->lut_entries, format_hex_bytes_no_wrap,
+ rl->lut, rl->lut_entries);
return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_LUT, msg, msg_len, 0,
0);
for (i = 0; i < ad->rss_key_size; i++)
rk->key[i] = (u8) random_u32 (&seed);
- avf_log_debug (ad, "config_rss_key: vsi_id %u rss_key_size %u key %U",
- rk->vsi_id, rk->key_len, format_hex_bytes, rk->key,
+ avf_log_debug (ad, "config_rss_key: vsi_id %u rss_key_size %u key 0x%U",
+ rk->vsi_id, rk->key_len, format_hex_bytes_no_wrap, rk->key,
rk->key_len);
return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_KEY, msg, msg_len, 0,
}
clib_error_t *
-avf_config_promisc_mode (vlib_main_t * vm, avf_device_t * ad)
+avf_config_promisc_mode (vlib_main_t * vm, avf_device_t * ad, int is_enable)
{
virtchnl_promisc_info_t pi = { 0 };
pi.vsi_id = ad->vsi_id;
- pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC;
+
+ if (is_enable)
+ pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC;
avf_log_debug (ad, "config_promisc_mode: unicast %s multicast %s",
pi.flags & FLAG_VF_UNICAST_PROMISC ? "on" : "off",
i, rxq->max_pkt_size, rxq->ring_len,
rxq->databuffer_size, rxq->dma_ring_addr);
- avf_txq_t *q = vec_elt_at_index (ad->txqs, i);
txq->vsi_id = ad->vsi_id;
+ txq->queue_id = i;
if (i < vec_len (ad->txqs))
{
- txq->queue_id = i;
+ avf_txq_t *q = vec_elt_at_index (ad->txqs, i);
txq->ring_len = q->size;
txq->dma_ring_addr = avf_dma_addr (vm, ad, (void *) q->descs);
}
imi->vecmap[0].vector_id = 1;
imi->vecmap[0].vsi_id = ad->vsi_id;
- imi->vecmap[0].rxq_map = 1;
+ imi->vecmap[0].rxq_map = (1 << ad->n_rx_queues) - 1;
+ imi->vecmap[0].txq_map = (1 << ad->n_tx_queues) - 1;
avf_log_debug (ad, "config_irq_map: vsi_id %u vector_id %u rxq_map %u",
ad->vsi_id, imi->vecmap[0].vector_id,
avf_aq_desc_t d = { 0 };
clib_error_t *error;
u32 rstat;
- int n_retry = 20;
+ f64 t0, t = 0, suspend_time = AVF_RESET_SUSPEND_TIME;
avf_log_debug (ad, "reset");
if ((error = avf_aq_desc_enq (vm, ad, &d, 0, 0)))
return error;
+ t0 = vlib_time_now (vm);
retry:
- vlib_process_suspend (vm, 10e-3);
+ vlib_process_suspend (vm, suspend_time);
+
rstat = avf_get_u32 (ad->bar0, AVFGEN_RSTAT);
if (rstat == 2 || rstat == 3)
- return 0;
+ {
+ avf_log_debug (ad, "reset completed in %.3fs", t);
+ return 0;
+ }
- if (--n_retry == 0)
+ t = vlib_time_now (vm) - t0;
+ if (t > AVF_RESET_MAX_WAIT_TIME)
{
- avf_log_err (ad, "reset failed");
+ avf_log_err (ad, "reset failed (timeout %.3fs)", t);
return clib_error_return (0, "reset failed (timeout)");
}
+ suspend_time *= 2;
goto retry;
}
virtchnl_vf_res_request_t res_req = { 0 };
clib_error_t *error;
u32 rstat;
- int n_retry = 20;
+ f64 t0, t, suspend_time = AVF_RESET_SUSPEND_TIME;
res_req.num_queue_pairs = num_queue_pairs;
res_req.num_queue_pairs);
}
+ t0 = vlib_time_now (vm);
retry:
- vlib_process_suspend (vm, 10e-3);
+ vlib_process_suspend (vm, suspend_time);
+ t = vlib_time_now (vm) - t0;
+
rstat = avf_get_u32 (ad->bar0, AVFGEN_RSTAT);
if ((rstat == VIRTCHNL_VFR_COMPLETED) || (rstat == VIRTCHNL_VFR_VFACTIVE))
goto done;
- if (--n_retry == 0)
- return clib_error_return (0, "reset failed (timeout)");
+ if (t > AVF_RESET_MAX_WAIT_TIME)
+ {
+ avf_log_err (ad, "request queues failed (timeout %.3f seconds)", t);
+ return clib_error_return (0, "request queues failed (timeout)");
+ }
+ suspend_time *= 2;
goto retry;
done:
avf_adminq_init (vm, ad);
- /* request more queues only if we need them */
- if ((error = avf_request_queues (vm, ad, tm->n_vlib_mains)))
+ if ((error = avf_request_queues (vm, ad, clib_max (tm->n_vlib_mains,
+ args->rxq_num))))
{
/* we failed to get more queues, but still we want to proceed */
clib_error_free (error);
if ((error = avf_op_disable_vlan_stripping (vm, ad)))
return error;
- if ((error = avf_config_promisc_mode (vm, ad)))
- return error;
-
/*
* Init Queues
*/
kbps = 25000000;
else if (speed == VIRTCHNL_LINK_SPEED_10GB)
kbps = 10000000;
+ else if (speed == VIRTCHNL_LINK_SPEED_5GB)
+ kbps = 5000000;
+ else if (speed == VIRTCHNL_LINK_SPEED_2_5GB)
+ kbps = 2500000;
else if (speed == VIRTCHNL_LINK_SPEED_1GB)
kbps = 1000000;
else if (speed == VIRTCHNL_LINK_SPEED_100MB)
static u32
avf_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags)
{
+ vlib_main_t *vm = vlib_get_main ();
avf_main_t *am = &avf_main;
- vlib_log_warn (am->log_class, "TODO");
+ avf_device_t *ad = vec_elt_at_index (am->devices, hw->dev_instance);
+ if (ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC (flags))
+ {
+ clib_error_t *error;
+ int promisc_enabled = (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) != 0;
+ u32 new_flags = promisc_enabled ?
+ ad->flags | AVF_DEVICE_F_PROMISC : ad->flags & ~AVF_DEVICE_F_PROMISC;
+
+ if (new_flags == ad->flags)
+ return flags;
+
+ if ((error = avf_config_promisc_mode (vm, ad, promisc_enabled)))
+ {
+ avf_log_err (ad, "%s: %U", format_clib_error, error);
+ clib_error_free (error);
+ return 0;
+ }
+
+ ad->flags = new_flags;
+ }
return 0;
}
#undef _
};
+static void
+avf_clear_hw_interface_counters (u32 instance)
+{
+ avf_main_t *am = &avf_main;
+ avf_device_t *ad = vec_elt_at_index (am->devices, instance);
+ clib_memcpy_fast (&ad->last_cleared_eth_stats,
+ &ad->eth_stats, sizeof (ad->eth_stats));
+}
+
/* *INDENT-OFF* */
VNET_DEVICE_CLASS (avf_device_class,) =
{
.name = "Adaptive Virtual Function (AVF) interface",
+ .clear_counters = avf_clear_hw_interface_counters,
.format_device = format_avf_device,
.format_device_name = format_avf_device_name,
.admin_up_down_function = avf_interface_admin_up_down,