ixgbe: add PF support
Signed-off-by: Intel
This commit is contained in:
parent
be2d648a2d
commit
00e30184da
@ -85,6 +85,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_mbx.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_rxtx.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_ethdev.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_fdir.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_pf.c
|
||||
|
||||
|
||||
# this lib depends upon:
|
||||
|
@ -85,6 +85,8 @@
|
||||
#define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
|
||||
#define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
|
||||
|
||||
#define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
|
||||
|
||||
#define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
|
||||
|
||||
static int eth_ixgbe_dev_init(struct eth_driver *eth_drv,
|
||||
@ -116,10 +118,6 @@ static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
|
||||
static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
|
||||
int on);
|
||||
static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
|
||||
static void ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
|
||||
static void ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
|
||||
static void ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev);
|
||||
static void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev);
|
||||
static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
|
||||
static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
|
||||
static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
|
||||
@ -165,7 +163,6 @@ static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
|
||||
static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
|
||||
static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
|
||||
|
||||
|
||||
/*
|
||||
* Define VF Stats MACRO for Non "cleared on read" register
|
||||
*/
|
||||
@ -362,6 +359,23 @@ ixgbe_is_sfp(struct ixgbe_hw *hw)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
|
||||
{
|
||||
uint32_t ctrl_ext;
|
||||
int32_t status;
|
||||
|
||||
status = ixgbe_reset_hw(hw);
|
||||
|
||||
ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
|
||||
/* Set PF Reset Done bit so PF/VF Mail Ops can work */
|
||||
ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
|
||||
IXGBE_WRITE_FLUSH(hw);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ixgbe_enable_intr(struct rte_eth_dev *dev)
|
||||
{
|
||||
@ -665,10 +679,16 @@ eth_ixgbe_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
|
||||
/* initialize the hw strip bitmap*/
|
||||
memset(hwstrip, 0, sizeof(*hwstrip));
|
||||
|
||||
/* let hardware know driver is loaded */
|
||||
/* initialize PF if max_vfs not zero */
|
||||
ixgbe_pf_host_init(eth_dev);
|
||||
|
||||
ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
|
||||
/* let hardware know driver is loaded */
|
||||
ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
|
||||
/* Set PF Reset Done bit so PF/VF Mail Ops can work */
|
||||
ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
|
||||
IXGBE_WRITE_FLUSH(hw);
|
||||
|
||||
if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
|
||||
PMD_INIT_LOG(DEBUG,
|
||||
@ -740,8 +760,14 @@ eth_ixgbevf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
|
||||
|
||||
hw->mac.num_rar_entries = hw->mac.max_rx_queues;
|
||||
diag = hw->mac.ops.reset_hw(hw);
|
||||
|
||||
if (diag != IXGBE_SUCCESS) {
|
||||
PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
|
||||
RTE_LOG(ERR, PMD, "\tThe MAC address is not valid.\n"
|
||||
"\tThe most likely cause of this error is that the VM host\n"
|
||||
"\thas not assigned a valid MAC address to this VF device.\n"
|
||||
"\tPlease consult the DPDK Release Notes (FAQ section) for\n"
|
||||
"\ta possible solution to this problem.\n");
|
||||
return (diag);
|
||||
}
|
||||
|
||||
@ -754,6 +780,7 @@ eth_ixgbevf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
|
||||
ETHER_ADDR_LEN * hw->mac.num_rar_entries);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Copy the permanent MAC address */
|
||||
ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
|
||||
ð_dev->data->mac_addrs[0]);
|
||||
@ -876,7 +903,7 @@ ixgbe_vlan_tpid_set(struct rte_eth_dev *dev, uint16_t tpid)
|
||||
IXGBE_WRITE_REG(hw, IXGBE_EXVET, tpid << 16);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct ixgbe_hw *hw =
|
||||
@ -892,7 +919,7 @@ ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct ixgbe_hw *hw =
|
||||
@ -979,7 +1006,7 @@ ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
|
||||
ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct ixgbe_hw *hw =
|
||||
@ -1007,7 +1034,7 @@ ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct ixgbe_hw *hw =
|
||||
@ -1132,6 +1159,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
|
||||
int err, link_up = 0, negotiate = 0;
|
||||
uint32_t speed = 0;
|
||||
int mask = 0;
|
||||
int status;
|
||||
|
||||
PMD_INIT_FUNC_TRACE();
|
||||
|
||||
@ -1150,9 +1178,14 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
|
||||
|
||||
/* reinitialize adapter
|
||||
* this calls reset and start */
|
||||
ixgbe_init_hw(hw);
|
||||
status = ixgbe_pf_reset_hw(hw);
|
||||
if (status != 0)
|
||||
return -1;
|
||||
hw->mac.ops.start_hw(hw);
|
||||
|
||||
/* configure PF module if SRIOV enabled */
|
||||
ixgbe_pf_host_configure(dev);
|
||||
|
||||
/* initialize transmission unit */
|
||||
ixgbe_dev_tx_init(dev);
|
||||
|
||||
@ -1257,7 +1290,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
|
||||
ixgbe_disable_intr(hw);
|
||||
|
||||
/* reset the NIC */
|
||||
ixgbe_reset_hw(hw);
|
||||
ixgbe_pf_reset_hw(hw);
|
||||
hw->adapter_stopped = FALSE;
|
||||
|
||||
/* stop adapter */
|
||||
@ -1285,8 +1318,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
|
||||
|
||||
PMD_INIT_FUNC_TRACE();
|
||||
|
||||
ixgbe_reset_hw(hw);
|
||||
|
||||
ixgbe_pf_reset_hw(hw);
|
||||
|
||||
ixgbe_dev_stop(dev);
|
||||
hw->adapter_stopped = 1;
|
||||
@ -1721,6 +1753,9 @@ ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
|
||||
intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
|
||||
}
|
||||
|
||||
if (eicr & IXGBE_EICR_MAILBOX)
|
||||
intr->flags |= IXGBE_FLAG_MAILBOX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1779,6 +1814,11 @@ ixgbe_dev_interrupt_action(struct rte_eth_dev *dev)
|
||||
|
||||
PMD_DRV_LOG(DEBUG, "intr action type %d\n", intr->flags);
|
||||
|
||||
if (intr->flags & IXGBE_FLAG_MAILBOX) {
|
||||
ixgbe_pf_mbx_process(dev);
|
||||
intr->flags &= ~IXGBE_FLAG_MAILBOX;
|
||||
}
|
||||
|
||||
if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
|
||||
/* get the link status before link update, for predicting later */
|
||||
memset(&link, 0, sizeof(link));
|
||||
@ -1834,6 +1874,13 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
|
||||
struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
|
||||
struct ixgbe_interrupt *intr =
|
||||
IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
|
||||
struct ixgbe_hw *hw =
|
||||
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
uint32_t eicr;
|
||||
|
||||
eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
|
||||
if (eicr & IXGBE_EICR_MAILBOX)
|
||||
ixgbe_pf_mbx_process(dev);
|
||||
|
||||
if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
|
||||
ixgbe_dev_link_update(dev, 0);
|
||||
@ -1842,7 +1889,7 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
}
|
||||
|
||||
PMD_DRV_LOG(DEBUG, "enable intr in delayed handler\n");
|
||||
PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]\n", eicr);
|
||||
ixgbe_enable_intr(dev);
|
||||
rte_intr_enable(&(dev->pci_dev->intr_handle));
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
/* need update link, bit flag */
|
||||
#define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
|
||||
#define IXGBE_FLAG_MAILBOX (uint32_t)(1 << 1)
|
||||
|
||||
/*
|
||||
* Defines that were not part of ixgbe_type.h as they are not used by the
|
||||
@ -95,6 +96,22 @@ struct ixgbe_hwstrip {
|
||||
uint32_t bitmap[IXGBE_HWSTRIP_BITMAP_SIZE];
|
||||
};
|
||||
|
||||
/*
|
||||
* VF data which used by PF host only
|
||||
*/
|
||||
#define IXGBE_MAX_VF_MC_ENTRIES 30
|
||||
struct ixgbe_vf_info {
|
||||
uint8_t vf_mac_addresses[ETHER_ADDR_LEN];
|
||||
uint16_t vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
|
||||
uint16_t num_vf_mc_hashes;
|
||||
uint16_t default_vf_vlan_id;
|
||||
uint16_t vlans_enabled;
|
||||
bool clear_to_send;
|
||||
uint16_t tx_rate;
|
||||
uint16_t vlan_count;
|
||||
uint8_t spoofchk_enabled;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure to store private data for each driver instance (for each port).
|
||||
*/
|
||||
@ -107,6 +124,7 @@ struct ixgbe_adapter {
|
||||
struct ixgbe_vfta shadow_vfta;
|
||||
struct ixgbe_hwstrip hwstrip;
|
||||
struct ixgbe_dcb_config dcb_config;
|
||||
struct ixgbe_vf_info *vfdata;
|
||||
};
|
||||
|
||||
#define IXGBE_DEV_PRIVATE_TO_HW(adapter)\
|
||||
@ -133,6 +151,9 @@ struct ixgbe_adapter {
|
||||
#define IXGBE_DEV_PRIVATE_TO_DCB_CFG(adapter) \
|
||||
(&((struct ixgbe_adapter *)adapter)->dcb_config)
|
||||
|
||||
#define IXGBE_DEV_PRIVATE_TO_P_VFDATA(adapter) \
|
||||
(&((struct ixgbe_adapter *)adapter)->vfdata)
|
||||
|
||||
/*
|
||||
* RX/TX function prototypes
|
||||
*/
|
||||
@ -216,4 +237,22 @@ int ixgbe_fdir_set_masks(struct rte_eth_dev *dev,
|
||||
|
||||
void ixgbe_configure_dcb(struct rte_eth_dev *dev);
|
||||
|
||||
/*
|
||||
* misc function prototypes
|
||||
*/
|
||||
void ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev);
|
||||
|
||||
void ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
|
||||
|
||||
void ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev);
|
||||
|
||||
void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev);
|
||||
|
||||
void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
|
||||
|
||||
void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
|
||||
|
||||
int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev);
|
||||
|
||||
|
||||
#endif /* _IXGBE_ETHDEV_H_ */
|
||||
|
564
lib/librte_pmd_ixgbe/ixgbe_pf.c
Normal file
564
lib/librte_pmd_ixgbe/ixgbe_pf.c
Normal file
@ -0,0 +1,564 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN 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 POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_ether.h>
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_memcpy.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_random.h>
|
||||
|
||||
#include "ixgbe/ixgbe_common.h"
|
||||
#include "ixgbe_ethdev.h"
|
||||
|
||||
#define IXGBE_MAX_VFTA (128)
|
||||
|
||||
static inline
|
||||
void eth_random_addr(uint8_t *addr)
|
||||
{
|
||||
uint64_t rand = rte_rand();
|
||||
uint8_t *p = (uint8_t*)&rand;
|
||||
|
||||
rte_memcpy(addr, p, ETHER_ADDR_LEN);
|
||||
addr[0] &= 0xfe; /* clear multicast bit */
|
||||
addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
dev_num_vf(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
return eth_dev->pci_dev->max_vfs;
|
||||
}
|
||||
|
||||
static inline
|
||||
int ixgbe_vf_perm_addr_gen(struct rte_eth_dev *dev, uint16_t vf_num)
|
||||
{
|
||||
unsigned char vf_mac_addr[ETHER_ADDR_LEN];
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
|
||||
uint16_t vfn;
|
||||
|
||||
for (vfn = 0; vfn < vf_num; vfn++) {
|
||||
eth_random_addr(vf_mac_addr);
|
||||
/* keep the random address as default */
|
||||
memcpy(vfinfo[vfn].vf_mac_addresses, vf_mac_addr,
|
||||
ETHER_ADDR_LEN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
ixgbe_mb_intr_setup(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct ixgbe_interrupt *intr =
|
||||
IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
|
||||
|
||||
intr->mask |= IXGBE_EICR_MAILBOX;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
struct ixgbe_vf_info **vfinfo =
|
||||
IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
|
||||
struct ixgbe_hw *hw =
|
||||
IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
|
||||
uint16_t vf_num;
|
||||
uint8_t nb_queue;
|
||||
|
||||
PMD_INIT_FUNC_TRACE();
|
||||
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
|
||||
if (0 == (vf_num = dev_num_vf(eth_dev)))
|
||||
return;
|
||||
|
||||
*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
|
||||
if (*vfinfo == NULL)
|
||||
rte_panic("Cannot allocate memory for private VF data\n");
|
||||
|
||||
if (vf_num >= ETH_32_POOLS) {
|
||||
nb_queue = 2;
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_64_POOLS;
|
||||
} else if (vf_num >= ETH_16_POOLS) {
|
||||
nb_queue = 4;
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_32_POOLS;
|
||||
} else {
|
||||
nb_queue = 8;
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).active = ETH_16_POOLS;
|
||||
}
|
||||
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool = nb_queue;
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = vf_num;
|
||||
RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = (uint16_t)(vf_num * nb_queue);
|
||||
|
||||
ixgbe_vf_perm_addr_gen(eth_dev, vf_num);
|
||||
|
||||
/* init_mailbox_params */
|
||||
hw->mbx.ops.init_params(hw);
|
||||
|
||||
/* set mb interrupt mask */
|
||||
ixgbe_mb_intr_setup(eth_dev);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
uint32_t vtctl, fcrth;
|
||||
uint32_t vfre_slot, vfre_offset;
|
||||
uint16_t vf_num;
|
||||
const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
|
||||
const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
|
||||
uint32_t gpie, gcr_ext;
|
||||
uint32_t vlanctrl;
|
||||
int i;
|
||||
|
||||
if (0 == (vf_num = dev_num_vf(eth_dev)))
|
||||
return -1;
|
||||
|
||||
/* enable VMDq and set the default pool for PF */
|
||||
vtctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
|
||||
vtctl |= IXGBE_VMD_CTL_VMDQ_EN;
|
||||
vtctl &= ~IXGBE_VT_CTL_POOL_MASK;
|
||||
vtctl |= RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx
|
||||
<< IXGBE_VT_CTL_POOL_SHIFT;
|
||||
vtctl |= IXGBE_VT_CTL_REPLEN;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vtctl);
|
||||
|
||||
vfre_offset = vf_num & VFRE_MASK;
|
||||
vfre_slot = (vf_num >> VFRE_SHIFT) > 0 ? 1 : 0;
|
||||
|
||||
/* Enable pools reserved to PF only */
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0) << vfre_offset);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot ^ 1), vfre_slot - 1);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0) << vfre_offset);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot ^ 1), vfre_slot - 1);
|
||||
|
||||
/* PFDMA Tx General Switch Control Enables VMDQ loopback */
|
||||
IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
|
||||
|
||||
/* clear VMDq map to perment rar 0 */
|
||||
hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
|
||||
|
||||
/* clear VMDq map to scan rar 127 */
|
||||
IXGBE_WRITE_REG(hw, IXGBE_MPSAR_LO(hw->mac.num_rar_entries), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_MPSAR_HI(hw->mac.num_rar_entries), 0);
|
||||
|
||||
/* set VMDq map to default PF pool */
|
||||
hw->mac.ops.set_vmdq(hw, 0, RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx);
|
||||
|
||||
/*
|
||||
* SW msut set GCR_EXT.VT_Mode the same as GPIE.VT_Mode
|
||||
*/
|
||||
gcr_ext = IXGBE_READ_REG(hw, IXGBE_GCR_EXT);
|
||||
gcr_ext &= ~IXGBE_GCR_EXT_VT_MODE_MASK;
|
||||
|
||||
gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
|
||||
gpie &= ~IXGBE_GPIE_VTMODE_MASK;
|
||||
gpie |= IXGBE_GPIE_MSIX_MODE;
|
||||
|
||||
switch (RTE_ETH_DEV_SRIOV(eth_dev).active) {
|
||||
case ETH_64_POOLS:
|
||||
gcr_ext |= IXGBE_GCR_EXT_VT_MODE_64;
|
||||
gpie |= IXGBE_GPIE_VTMODE_64;
|
||||
break;
|
||||
case ETH_32_POOLS:
|
||||
gcr_ext |= IXGBE_GCR_EXT_VT_MODE_32;
|
||||
gpie |= IXGBE_GPIE_VTMODE_32;
|
||||
break;
|
||||
case ETH_16_POOLS:
|
||||
gcr_ext |= IXGBE_GCR_EXT_VT_MODE_16;
|
||||
gpie |= IXGBE_GPIE_VTMODE_16;
|
||||
break;
|
||||
}
|
||||
|
||||
IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, gcr_ext);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
|
||||
|
||||
/*
|
||||
* enable vlan filtering and allow all vlan tags through
|
||||
*/
|
||||
vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
|
||||
vlanctrl |= IXGBE_VLNCTRL_VFE ; /* enable vlan filters */
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
|
||||
|
||||
/* VFTA - enable all vlan filters */
|
||||
for (i = 0; i < IXGBE_MAX_VFTA; i++) {
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
/* Enable MAC Anti-Spoofing */
|
||||
hw->mac.ops.set_mac_anti_spoofing(hw, FALSE, vf_num);
|
||||
|
||||
/* set flow control threshold to max to avoid tx switch hang */
|
||||
for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
|
||||
IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(i), 0);
|
||||
fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i)) - 32;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(i), fcrth);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
set_rx_mode(struct rte_eth_dev *dev)
|
||||
{
|
||||
struct rte_eth_dev_data *dev_data =
|
||||
(struct rte_eth_dev_data*)dev->data->dev_private;
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
u32 fctrl, vmolr = IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE;
|
||||
uint16_t vfn = dev_num_vf(dev);
|
||||
|
||||
/* Check for Promiscuous and All Multicast modes */
|
||||
fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
|
||||
|
||||
/* set all bits that we expect to always be set */
|
||||
fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */
|
||||
fctrl |= IXGBE_FCTRL_BAM;
|
||||
|
||||
/* clear the bits we are changing the status of */
|
||||
fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
|
||||
|
||||
if (dev_data->promiscuous) {
|
||||
fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
|
||||
vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_MPE);
|
||||
/* don't hardware filter vlans in promisc mode */
|
||||
ixgbe_vlan_hw_filter_disable(dev);
|
||||
} else {
|
||||
if (dev_data->all_multicast) {
|
||||
fctrl |= IXGBE_FCTRL_MPE;
|
||||
vmolr |= IXGBE_VMOLR_MPE;
|
||||
} else {
|
||||
vmolr |= IXGBE_VMOLR_ROMPE;
|
||||
}
|
||||
ixgbe_vlan_hw_filter_enable(dev);
|
||||
}
|
||||
|
||||
if (hw->mac.type != ixgbe_mac_82598EB) {
|
||||
vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(vfn)) &
|
||||
~(IXGBE_VMOLR_MPE | IXGBE_VMOLR_ROMPE |
|
||||
IXGBE_VMOLR_ROPE);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vfn), vmolr);
|
||||
}
|
||||
|
||||
IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
|
||||
|
||||
if (dev->data->dev_conf.rxmode.hw_vlan_strip)
|
||||
ixgbe_vlan_hw_strip_enable_all(dev);
|
||||
else
|
||||
ixgbe_vlan_hw_strip_disable_all(dev);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ixgbe_vf_reset_event(struct rte_eth_dev *dev, uint16_t vf)
|
||||
{
|
||||
struct ixgbe_hw *hw =
|
||||
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
|
||||
int rar_entry = hw->mac.num_rar_entries - (vf + 1);
|
||||
uint32_t vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
|
||||
|
||||
vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_ROMPE |
|
||||
IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
|
||||
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), 0);
|
||||
|
||||
/* reset multicast table array for vf */
|
||||
vfinfo[vf].num_vf_mc_hashes = 0;
|
||||
|
||||
/* reset rx mode */
|
||||
set_rx_mode(dev);
|
||||
|
||||
hw->mac.ops.clear_rar(hw, rar_entry);
|
||||
}
|
||||
|
||||
static inline void
|
||||
ixgbe_vf_reset_msg(struct rte_eth_dev *dev, uint16_t vf)
|
||||
{
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
uint32_t reg;
|
||||
uint32_t reg_offset, vf_shift;
|
||||
const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */
|
||||
const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1);
|
||||
|
||||
vf_shift = vf & VFRE_MASK;
|
||||
reg_offset = (vf >> VFRE_SHIFT) > 0 ? 1 : 0;
|
||||
|
||||
/* enable transmit and receive for vf */
|
||||
reg = IXGBE_READ_REG(hw, IXGBE_VFTE(reg_offset));
|
||||
reg |= (reg | (1 << vf_shift));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), reg);
|
||||
|
||||
reg = IXGBE_READ_REG(hw, IXGBE_VFRE(reg_offset));
|
||||
reg |= (reg | (1 << vf_shift));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), reg);
|
||||
|
||||
/* Enable counting of spoofed packets in the SSVPC register */
|
||||
reg = IXGBE_READ_REG(hw, IXGBE_VMECM(reg_offset));
|
||||
reg |= (1 << vf_shift);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_VMECM(reg_offset), reg);
|
||||
|
||||
ixgbe_vf_reset_event(dev, vf);
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_vf_reset(struct rte_eth_dev *dev, uint16_t vf, uint32_t *msgbuf)
|
||||
{
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
|
||||
unsigned char *vf_mac = vfinfo[vf].vf_mac_addresses;
|
||||
int rar_entry = hw->mac.num_rar_entries - (vf + 1);
|
||||
uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
|
||||
|
||||
ixgbe_vf_reset_msg(dev, vf);
|
||||
|
||||
hw->mac.ops.set_rar(hw, rar_entry, vf_mac, vf, IXGBE_RAH_AV);
|
||||
|
||||
/* reply to reset with ack and vf mac address */
|
||||
msgbuf[0] = IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK;
|
||||
rte_memcpy(new_mac, vf_mac, ETHER_ADDR_LEN);
|
||||
/*
|
||||
* Piggyback the multicast filter type so VF can compute the
|
||||
* correct vectors
|
||||
*/
|
||||
msgbuf[3] = hw->mac.mc_filter_type;
|
||||
ixgbe_write_mbx(hw, msgbuf, IXGBE_VF_PERMADDR_MSG_LEN, vf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_vf_set_mac_addr(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
|
||||
{
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
|
||||
int rar_entry = hw->mac.num_rar_entries - (vf + 1);
|
||||
uint8_t *new_mac = (uint8_t *)(&msgbuf[1]);
|
||||
|
||||
if (is_valid_assigned_ether_addr((struct ether_addr*)new_mac)) {
|
||||
rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, 6);
|
||||
return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, IXGBE_RAH_AV);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_vf_set_multicast(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
|
||||
{
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
|
||||
int nb_entries = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
|
||||
IXGBE_VT_MSGINFO_SHIFT;
|
||||
uint16_t *hash_list = (uint16_t *)&msgbuf[1];
|
||||
uint32_t mta_idx;
|
||||
uint32_t mta_shift;
|
||||
const uint32_t IXGBE_MTA_INDEX_MASK = 0x7F;
|
||||
const uint32_t IXGBE_MTA_BIT_SHIFT = 5;
|
||||
const uint32_t IXGBE_MTA_BIT_MASK = (0x1 << IXGBE_MTA_BIT_SHIFT) - 1;
|
||||
uint32_t reg_val;
|
||||
int i;
|
||||
|
||||
/* only so many hash values supported */
|
||||
nb_entries = RTE_MIN(nb_entries, IXGBE_MAX_VF_MC_ENTRIES);
|
||||
|
||||
/* store the mc entries */
|
||||
vfinfo->num_vf_mc_hashes = (uint16_t)nb_entries;
|
||||
for (i = 0; i < nb_entries; i++) {
|
||||
vfinfo->vf_mc_hashes[i] = hash_list[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {
|
||||
mta_idx = (vfinfo->vf_mc_hashes[i] >> IXGBE_MTA_BIT_SHIFT)
|
||||
& IXGBE_MTA_INDEX_MASK;
|
||||
mta_shift = vfinfo->vf_mc_hashes[i] & IXGBE_MTA_BIT_MASK;
|
||||
reg_val = IXGBE_READ_REG(hw, IXGBE_MTA(mta_idx));
|
||||
reg_val |= (1 << mta_shift);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_MTA(mta_idx), reg_val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_vf_set_vlan(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
|
||||
{
|
||||
int add, vid;
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
struct ixgbe_vf_info *vfinfo =
|
||||
*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
|
||||
|
||||
add = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK)
|
||||
>> IXGBE_VT_MSGINFO_SHIFT;
|
||||
vid = (msgbuf[1] & IXGBE_VLVF_VLANID_MASK);
|
||||
|
||||
if (add)
|
||||
vfinfo[vf].vlan_count++;
|
||||
else if (vfinfo[vf].vlan_count)
|
||||
vfinfo[vf].vlan_count--;
|
||||
return hw->mac.ops.set_vfta(hw, vid, vf, (bool)add);
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
|
||||
{
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
uint32_t new_mtu = msgbuf[1];
|
||||
uint32_t max_frs;
|
||||
int max_frame = new_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
|
||||
|
||||
/* Only X540 supports jumbo frames in IOV mode */
|
||||
if (hw->mac.type != ixgbe_mac_X540)
|
||||
return -1;
|
||||
|
||||
if ((max_frame < ETHER_MIN_LEN) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
|
||||
return -1;
|
||||
|
||||
max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
|
||||
IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
|
||||
if (max_frs < new_mtu) {
|
||||
max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ixgbe_rcv_msg_from_vf(struct rte_eth_dev *dev, uint16_t vf)
|
||||
{
|
||||
uint16_t mbx_size = IXGBE_VFMAILBOX_SIZE;
|
||||
uint32_t msgbuf[IXGBE_VFMAILBOX_SIZE];
|
||||
int32_t retval;
|
||||
struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
|
||||
retval = ixgbe_read_mbx(hw, msgbuf, mbx_size, vf);
|
||||
if (retval) {
|
||||
RTE_LOG(ERR, PMD, "Error mbx recv msg from VF %d\n", vf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* do nothing with the message already been processed */
|
||||
if (msgbuf[0] & (IXGBE_VT_MSGTYPE_ACK | IXGBE_VT_MSGTYPE_NACK))
|
||||
return retval;
|
||||
|
||||
/* flush the ack before we write any messages back */
|
||||
IXGBE_WRITE_FLUSH(hw);
|
||||
|
||||
/* perform VF reset */
|
||||
if (msgbuf[0] == IXGBE_VF_RESET) {
|
||||
return ixgbe_vf_reset(dev, vf, msgbuf);
|
||||
}
|
||||
|
||||
/* check & process VF to PF mailbox message */
|
||||
switch ((msgbuf[0] & 0xFFFF)) {
|
||||
case IXGBE_VF_SET_MAC_ADDR:
|
||||
retval = ixgbe_vf_set_mac_addr(dev, vf, msgbuf);
|
||||
break;
|
||||
case IXGBE_VF_SET_MULTICAST:
|
||||
retval = ixgbe_vf_set_multicast(dev, vf, msgbuf);
|
||||
break;
|
||||
case IXGBE_VF_SET_LPE:
|
||||
retval = ixgbe_set_vf_lpe(dev, vf, msgbuf);
|
||||
break;
|
||||
case IXGBE_VF_SET_VLAN:
|
||||
retval = ixgbe_vf_set_vlan(dev, vf, msgbuf);
|
||||
break;
|
||||
default:
|
||||
RTE_LOG(DEBUG, PMD, "Unhandled Msg %8.8x\n", (unsigned) msgbuf[0]);
|
||||
retval = IXGBE_ERR_MBX;
|
||||
break;
|
||||
}
|
||||
|
||||
/* response the VF according to the message process result */
|
||||
if (retval)
|
||||
msgbuf[0] |= IXGBE_VT_MSGTYPE_NACK;
|
||||
else
|
||||
msgbuf[0] |= IXGBE_VT_MSGTYPE_ACK;
|
||||
|
||||
msgbuf[0] |= IXGBE_VT_MSGTYPE_CTS;
|
||||
|
||||
ixgbe_write_mbx(hw, msgbuf, 1, vf);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ixgbe_rcv_ack_from_vf(struct rte_eth_dev *dev, uint16_t vf)
|
||||
{
|
||||
uint32_t msg = IXGBE_VT_MSGTYPE_NACK;
|
||||
struct ixgbe_hw *hw =
|
||||
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
|
||||
|
||||
ixgbe_write_mbx(hw, &msg, 1, vf);
|
||||
}
|
||||
|
||||
void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
uint16_t vf;
|
||||
struct ixgbe_hw *hw =
|
||||
IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
|
||||
|
||||
for (vf = 0; vf < dev_num_vf(eth_dev); vf++) {
|
||||
/* check & process vf function level reset */
|
||||
if (!ixgbe_check_for_rst(hw, vf))
|
||||
ixgbe_vf_reset_event(eth_dev, vf);
|
||||
|
||||
/* check & process vf mailbox messages */
|
||||
if (!ixgbe_check_for_msg(hw, vf))
|
||||
ixgbe_rcv_msg_from_vf(eth_dev, vf);
|
||||
|
||||
/* check & process acks from vf */
|
||||
if (!ixgbe_check_for_ack(hw, vf))
|
||||
ixgbe_rcv_ack_from_vf(eth_dev, vf);
|
||||
}
|
||||
}
|
@ -141,6 +141,7 @@ struct igb_rx_queue {
|
||||
#endif
|
||||
uint16_t rx_free_thresh; /**< max free RX desc to hold. */
|
||||
uint16_t queue_id; /**< RX queue index. */
|
||||
uint16_t reg_idx; /**< RX queue register index. */
|
||||
uint8_t port_id; /**< Device port identifier. */
|
||||
uint8_t crc_len; /**< 0 if CRC stripped, 4 otherwise. */
|
||||
uint8_t drop_en; /**< If not 0, set SRRCTL.Drop_En. */
|
||||
@ -194,6 +195,7 @@ struct igb_tx_queue {
|
||||
uint16_t tx_next_dd; /**< next desc to scan for DD bit */
|
||||
uint16_t tx_next_rs; /**< next desc to set RS bit */
|
||||
uint16_t queue_id; /**< TX queue index. */
|
||||
uint16_t reg_idx; /**< TX queue register index. */
|
||||
uint8_t port_id; /**< Device port identifier. */
|
||||
uint8_t pthresh; /**< Prefetch threshold register. */
|
||||
uint8_t hthresh; /**< Host threshold register. */
|
||||
@ -1956,6 +1958,8 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
|
||||
txq->hthresh = tx_conf->tx_thresh.hthresh;
|
||||
txq->wthresh = tx_conf->tx_thresh.wthresh;
|
||||
txq->queue_id = queue_idx;
|
||||
txq->reg_idx = (uint16_t)((RTE_ETH_DEV_SRIOV(dev).active == 0) ?
|
||||
queue_idx : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + queue_idx);
|
||||
txq->port_id = dev->data->port_id;
|
||||
txq->txq_flags = tx_conf->txq_flags;
|
||||
|
||||
@ -1965,7 +1969,7 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
|
||||
if (hw->mac.type == ixgbe_mac_82599_vf)
|
||||
txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFTDT(queue_idx));
|
||||
else
|
||||
txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(queue_idx));
|
||||
txq->tdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_TDT(txq->reg_idx));
|
||||
|
||||
txq->tx_ring_phys_addr = (uint64_t) tz->phys_addr;
|
||||
txq->tx_ring = (union ixgbe_adv_tx_desc *) tz->addr;
|
||||
@ -2180,6 +2184,8 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
|
||||
rxq->nb_rx_desc = nb_desc;
|
||||
rxq->rx_free_thresh = rx_conf->rx_free_thresh;
|
||||
rxq->queue_id = queue_idx;
|
||||
rxq->reg_idx = (uint16_t)((RTE_ETH_DEV_SRIOV(dev).active == 0) ?
|
||||
queue_idx : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx + queue_idx);
|
||||
rxq->port_id = dev->data->port_id;
|
||||
rxq->crc_len = (uint8_t) ((dev->data->dev_conf.rxmode.hw_strip_crc) ?
|
||||
0 : ETHER_CRC_LEN);
|
||||
@ -2200,10 +2206,18 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
|
||||
/*
|
||||
* Modified to setup VFRDT for Virtual Function
|
||||
*/
|
||||
if (hw->mac.type == ixgbe_mac_82599_vf)
|
||||
rxq->rdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDT(queue_idx));
|
||||
else
|
||||
rxq->rdt_reg_addr = IXGBE_PCI_REG_ADDR(hw, IXGBE_RDT(queue_idx));
|
||||
if (hw->mac.type == ixgbe_mac_82599_vf) {
|
||||
rxq->rdt_reg_addr =
|
||||
IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDT(queue_idx));
|
||||
rxq->rdh_reg_addr =
|
||||
IXGBE_PCI_REG_ADDR(hw, IXGBE_VFRDH(queue_idx));
|
||||
}
|
||||
else {
|
||||
rxq->rdt_reg_addr =
|
||||
IXGBE_PCI_REG_ADDR(hw, IXGBE_RDT(rxq->reg_idx));
|
||||
rxq->rdh_reg_addr =
|
||||
IXGBE_PCI_REG_ADDR(hw, IXGBE_RDH(rxq->reg_idx));
|
||||
}
|
||||
|
||||
rxq->rx_ring_phys_addr = (uint64_t) rz->phys_addr;
|
||||
rxq->rx_ring = (union ixgbe_adv_rx_desc *) rz->addr;
|
||||
@ -3123,14 +3137,14 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
|
||||
|
||||
/* Setup the Base and Length of the Rx Descriptor Rings */
|
||||
bus_addr = rxq->rx_ring_phys_addr;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDBAL(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDBAL(rxq->reg_idx),
|
||||
(uint32_t)(bus_addr & 0x00000000ffffffffULL));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDBAH(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDBAH(rxq->reg_idx),
|
||||
(uint32_t)(bus_addr >> 32));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDLEN(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDLEN(rxq->reg_idx),
|
||||
rxq->nb_rx_desc * sizeof(union ixgbe_adv_rx_desc));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDH(i), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDT(i), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDH(rxq->reg_idx), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDT(rxq->reg_idx), 0);
|
||||
|
||||
/* Configure the SRRCTL register */
|
||||
#ifdef RTE_HEADER_SPLIT_ENABLE
|
||||
@ -3145,7 +3159,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
|
||||
IXGBE_PSRTYPE_UDPHDR |
|
||||
IXGBE_PSRTYPE_IPV4HDR |
|
||||
IXGBE_PSRTYPE_IPV6HDR;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(i), psrtype);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx), psrtype);
|
||||
}
|
||||
srrctl = ((dev->data->dev_conf.rxmode.split_hdr_size <<
|
||||
IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
|
||||
@ -3258,15 +3272,15 @@ ixgbe_dev_tx_init(struct rte_eth_dev *dev)
|
||||
txq = dev->data->tx_queues[i];
|
||||
|
||||
bus_addr = txq->tx_ring_phys_addr;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDBAL(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDBAL(txq->reg_idx),
|
||||
(uint32_t)(bus_addr & 0x00000000ffffffffULL));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDBAH(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDBAH(txq->reg_idx),
|
||||
(uint32_t)(bus_addr >> 32));
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDLEN(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDLEN(txq->reg_idx),
|
||||
txq->nb_tx_desc * sizeof(union ixgbe_adv_tx_desc));
|
||||
/* Setup the HW Tx Head and TX Tail descriptor pointers */
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDH(i), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDT(i), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDH(txq->reg_idx), 0);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TDT(txq->reg_idx), 0);
|
||||
|
||||
/*
|
||||
* Disable Tx Head Writeback RO bit, since this hoses
|
||||
@ -3275,9 +3289,9 @@ ixgbe_dev_tx_init(struct rte_eth_dev *dev)
|
||||
switch (hw->mac.type) {
|
||||
case ixgbe_mac_82598EB:
|
||||
txctrl = IXGBE_READ_REG(hw,
|
||||
IXGBE_DCA_TXCTRL(i));
|
||||
IXGBE_DCA_TXCTRL(txq->reg_idx));
|
||||
txctrl &= ~IXGBE_DCA_TXCTRL_DESC_WRO_EN;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i),
|
||||
IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(txq->reg_idx),
|
||||
txctrl);
|
||||
break;
|
||||
|
||||
@ -3329,11 +3343,11 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
|
||||
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
||||
txq = dev->data->tx_queues[i];
|
||||
/* Setup Transmit Threshold Registers */
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
|
||||
txdctl |= txq->pthresh & 0x7F;
|
||||
txdctl |= ((txq->hthresh & 0x7F) << 8);
|
||||
txdctl |= ((txq->wthresh & 0x7F) << 16);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(i), txdctl);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl);
|
||||
}
|
||||
|
||||
if (hw->mac.type != ixgbe_mac_82598EB) {
|
||||
@ -3343,16 +3357,17 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
|
||||
}
|
||||
|
||||
for (i = 0; i < dev->data->nb_tx_queues; i++) {
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
|
||||
txq = dev->data->tx_queues[i];
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
|
||||
txdctl |= IXGBE_TXDCTL_ENABLE;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(i), txdctl);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl);
|
||||
|
||||
/* Wait until TX Enable ready */
|
||||
if (hw->mac.type == ixgbe_mac_82599EB) {
|
||||
poll_ms = 10;
|
||||
do {
|
||||
rte_delay_ms(1);
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
|
||||
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx));
|
||||
} while (--poll_ms && !(txdctl & IXGBE_TXDCTL_ENABLE));
|
||||
if (!poll_ms)
|
||||
PMD_INIT_LOG(ERR, "Could not enable "
|
||||
@ -3361,21 +3376,21 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
|
||||
}
|
||||
for (i = 0; i < dev->data->nb_rx_queues; i++) {
|
||||
rxq = dev->data->rx_queues[i];
|
||||
rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));
|
||||
rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
|
||||
rxdctl |= IXGBE_RXDCTL_ENABLE;
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(i), rxdctl);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), rxdctl);
|
||||
|
||||
/* Wait until RX Enable ready */
|
||||
poll_ms = 10;
|
||||
do {
|
||||
rte_delay_ms(1);
|
||||
rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));
|
||||
rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
|
||||
} while (--poll_ms && !(rxdctl & IXGBE_RXDCTL_ENABLE));
|
||||
if (!poll_ms)
|
||||
PMD_INIT_LOG(ERR, "Could not enable "
|
||||
"Rx Queue %d\n", i);
|
||||
rte_wmb();
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDT(i), rxq->nb_rx_desc - 1);
|
||||
IXGBE_WRITE_REG(hw, IXGBE_RDT(rxq->reg_idx), rxq->nb_rx_desc - 1);
|
||||
}
|
||||
|
||||
/* Enable Receive engine */
|
||||
|
Loading…
x
Reference in New Issue
Block a user