Skip to content

Commit

Permalink
net/ixgbevf: add full link status check option
Browse files Browse the repository at this point in the history
[ upstream commit bd28203 ]

To get the VF's link status by calling 'rte_eth_link_get_nowait()', the
VF not only check PF's physical link status, but also check the mailbox
running status. And mailbox checking will generate mailbox interrupt in
PF, it will be worse if many VFs are running in the system, the PF will
have to handle many interrrupts.

Normally, checking the PF's physical link status is enough for nowait.
For different scenarios, adding an 'pflink_fullchk' option to control
whether to check the link fully or not.

Fixes: 91546fb ("net/ixgbevf: fix link state")

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Scott Daniels <daniels@research.att.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
  • Loading branch information
haiyuewa authored and kevintraynor committed Jun 24, 2019
1 parent 4dfbacf commit 6d58d68
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/guides/nics/ixgbe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,31 @@ To guarantee the constraint, capabilities in dev_conf.rxmode.offloads will be ch

fdir_conf->mode will also be checked.

VF Runtime Options
^^^^^^^^^^^^^^^^^^

The following ``devargs`` options can be enabled at runtime. They must
be passed as part of EAL arguments. For example,

.. code-block:: console
testpmd -w af:10.0,pflink_fullchk=1 -- -i
- ``pflink_fullchk`` (default **0**)

When calling ``rte_eth_link_get_nowait()`` to get VF link status,
this option is used to control how VF synchronizes its status with
PF's. If set, VF will not only check the PF's physical link status
by reading related register, but also check the mailbox status. We
call this behavior as fully checking. And checking mailbox will
trigger PF's mailbox interrupt generation. If unset, the application
can get the VF's link status quickly by just reading the PF's link
status register, this will avoid the whole system's mailbox interrupt
generation.

``rte_eth_link_get()`` will still use the mailbox method regardless
of the pflink_fullchk setting.

RX Burst Size
^^^^^^^^^^^^^

Expand Down
63 changes: 63 additions & 0 deletions drivers/net/ixgbe/ixgbe_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <rte_bus_pci.h>
#include <rte_branch_prediction.h>
#include <rte_memory.h>
#include <rte_kvargs.h>
#include <rte_eal.h>
#include <rte_alarm.h>
#include <rte_ether.h>
Expand Down Expand Up @@ -126,6 +127,13 @@
#define IXGBE_EXVET_VET_EXT_SHIFT 16
#define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000

#define IXGBEVF_DEVARG_PFLINK_FULLCHK "pflink_fullchk"

static const char * const ixgbevf_valid_arguments[] = {
IXGBEVF_DEVARG_PFLINK_FULLCHK,
NULL
};

static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params);
static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
Expand Down Expand Up @@ -1542,6 +1550,45 @@ generate_random_mac_addr(struct ether_addr *mac_addr)
memcpy(&mac_addr->addr_bytes[3], &random, 3);
}

static int
devarg_handle_int(__rte_unused const char *key, const char *value,
void *extra_args)
{
uint16_t *n = extra_args;

if (value == NULL || extra_args == NULL)
return -EINVAL;

*n = (uint16_t)strtoul(value, NULL, 0);
if (*n == USHRT_MAX && errno == ERANGE)
return -1;

return 0;
}

static void
ixgbevf_parse_devargs(struct ixgbe_adapter *adapter,
struct rte_devargs *devargs)
{
struct rte_kvargs *kvlist;
uint16_t pflink_fullchk;

if (devargs == NULL)
return;

kvlist = rte_kvargs_parse(devargs->args, ixgbevf_valid_arguments);
if (kvlist == NULL)
return;

if (rte_kvargs_count(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK) == 1 &&
rte_kvargs_process(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK,
devarg_handle_int, &pflink_fullchk) == 0 &&
pflink_fullchk == 1)
adapter->pflink_fullchk = 1;

rte_kvargs_free(kvlist);
}

/*
* Virtual Function device init
*/
Expand Down Expand Up @@ -1589,6 +1636,9 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
return 0;
}

ixgbevf_parse_devargs(eth_dev->data->dev_private,
pci_dev->device.devargs);

rte_eth_copy_pci_info(eth_dev, pci_dev);

hw->device_id = pci_dev->id.device_id;
Expand Down Expand Up @@ -3888,6 +3938,8 @@ static int
ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
int *link_up, int wait_to_complete)
{
struct ixgbe_adapter *adapter = container_of(hw,
struct ixgbe_adapter, hw);
struct ixgbe_mbx_info *mbx = &hw->mbx;
struct ixgbe_mac_info *mac = &hw->mac;
uint32_t links_reg, in_msg;
Expand Down Expand Up @@ -3948,6 +4000,15 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
*speed = IXGBE_LINK_SPEED_UNKNOWN;
}

if (wait_to_complete == 0 && adapter->pflink_fullchk == 0) {
if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
mac->get_link_status = true;
else
mac->get_link_status = false;

goto out;
}

/* if the read failed it could just be a mailbox collision, best wait
* until we are called again and don't report an error
*/
Expand Down Expand Up @@ -8611,6 +8672,8 @@ RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");

RTE_INIT(ixgbe_init_log)
{
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ixgbe/ixgbe_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ struct ixgbe_adapter {

/* For RSS reta table update */
uint8_t rss_reta_updated;

/* Used for VF link sync with PF's physical and logical (by checking
* mailbox status) link status.
*/
uint8_t pflink_fullchk;
};

struct ixgbe_vf_representor {
Expand Down

0 comments on commit 6d58d68

Please sign in to comment.