* [PATCH 6/7] ixgbe: remove useless return
From: Stephen Hemminger @ 2017-01-09 23:30 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
In-Reply-To: <20170109233022.31154-1-stephen@networkplumber.org>
If all goto's lead to a return, then better to get rid of goto.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/ixgbe/ixgbe_82599_bypass.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_82599_bypass.c b/drivers/net/ixgbe/ixgbe_82599_bypass.c
index de9fa5a7..af55cc0a 100644
--- a/drivers/net/ixgbe/ixgbe_82599_bypass.c
+++ b/drivers/net/ixgbe/ixgbe_82599_bypass.c
@@ -73,7 +73,7 @@ ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed)
&eeprom_data);
if (status) {
PMD_DRV_LOG(ERR, "Failed to read Rx Rate Select RS0");
- goto out;
+ return;
}
eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
@@ -83,7 +83,7 @@ ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed)
eeprom_data);
if (status) {
PMD_DRV_LOG(ERR, "Failed to write Rx Rate Select RS0");
- goto out;
+ return;
}
/* Set RS1 */
@@ -92,7 +92,7 @@ ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed)
&eeprom_data);
if (status) {
PMD_DRV_LOG(ERR, "Failed to read Rx Rate Select RS1");
- goto out;
+ return;
}
eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
@@ -102,10 +102,8 @@ ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed)
eeprom_data);
if (status) {
PMD_DRV_LOG(ERR, "Failed to write Rx Rate Select RS1");
- goto out;
+ return;
}
-out:
- return;
}
/**
--
2.11.0
^ permalink raw reply related
* [PATCH 7/7] igb: remove useless return's
From: Stephen Hemminger @ 2017-01-09 23:30 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
In-Reply-To: <20170109233022.31154-1-stephen@networkplumber.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/e1000/igb_pf.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c
index 67da3c24..15bf8bfe 100644
--- a/drivers/net/e1000/igb_pf.c
+++ b/drivers/net/e1000/igb_pf.c
@@ -125,8 +125,6 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev)
/* set mb interrupt mask */
igb_mb_intr_setup(eth_dev);
-
- return;
}
void igb_pf_host_uninit(struct rte_eth_dev *dev)
--
2.11.0
^ permalink raw reply related
* Re: [dpdk-stable] [PATCH] ixgbe: fix wrong VMDq function name
From: Lu, Wenzhuo @ 2017-01-10 1:02 UTC (permalink / raw)
To: Yigit, Ferruh, Iremonger, Bernard, dev@dpdk.org; +Cc: stable@dpdk.org
In-Reply-To: <9834bf39-1468-cb3f-4e94-8186f5c1b4bc@intel.com>
Hi Ferruh,
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, January 10, 2017 1:37 AM
> To: Iremonger, Bernard; Lu, Wenzhuo; dev@dpdk.org
> Cc: stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] ixgbe: fix wrong VMDq function name
>
> On 1/9/2017 5:06 PM, Iremonger, Bernard wrote:
> >> -----Original Message-----
> >> From: Lu, Wenzhuo
> >> Sent: Friday, January 6, 2017 2:31 AM
> >> To: dev@dpdk.org
> >> Cc: Iremonger, Bernard <bernard.iremonger@intel.com>; Lu, Wenzhuo
> >> <wenzhuo.lu@intel.com>; stable@dpdk.org
> >> Subject: [PATCH] ixgbe: fix wrong VMDq function name
> >>
> >> The function name ixgbe_vmdq_mode_check is not right.
> >> This function checks if Virtualization Technology is enabled. It's
> >> for both VMDq and IOV.
> >> Others may be misled by the current name.
> >>
> >> Fixes: fe3a45fd4104 ("ixgbe: add VMDq support")
> >>
> >> CC: stable@dpdk.org
> >> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> >
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >
>
> Hi Wenzhuo,
>
> This patch seems on top of main repo, would you mind sending a new version
> rebased on next-net?
Yes, it's based on the main repo. I'll send a V2 for next-net.
>
> You can keep the Bernard's ack.
>
> Thanks,
> ferruh
^ permalink raw reply
* Re: [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API
From: Tiwei Bie @ 2017-01-10 2:08 UTC (permalink / raw)
To: Thomas Monjalon
Cc: Ananyev, Konstantin, Adrien Mazarguil, dev, Lu, Wenzhuo,
Mcnamara, John, olivier.matz, Zhang, Helin, Dai, Wei,
Wang, Xiao W
In-Reply-To: <1542539.LCBRG7nZDl@xps13>
On Mon, Jan 09, 2017 at 12:26:53PM +0100, Thomas Monjalon wrote:
> 2017-01-09 11:57, Tiwei Bie:
> > On Sun, Jan 08, 2017 at 08:39:55PM +0800, Ananyev, Konstantin wrote:
> > > > Well my first reply to this thread was asking why isn't the whole API global
> > > > from the start then?
> > >
> > > That's good question, and my preference would always be to have the
> > > API to configure this feature as generic one.
> > > I guess the main reason why it is not right now we don't reach an agreement
> > > how this API should look like:
> > > http://dpdk.org/ml/archives/dev/2016-September/047810.html
> > > But I'll leave it to the author to provide the real reason here.
> >
> > Yes, currently this work just provided a thin layer over 82599's
> > hardware MACsec offload support to allow users configure 82599's
> > MACsec offload engine. The current API may be too specific and may
> > need a rework to be used with other NICs.
>
> I think it is a really good approach to start such API privately in a driver.
> It will give us more time and experience to design a proper generic API.
>
> Regarding the mbuf flag, it looks straight-forward, and as it is IEEE
> standardized, I do not see any objection to add it now.
> However, I will wait for the approval of Olivier - as maintainer of mbuf.
>
I see. Thank you very much for your comments! :-)
Best regards,
Tiwei Bie
^ permalink raw reply
* [PATCH v2] ixgbe: fix wrong VMDq function name
From: Wenzhuo Lu @ 2017-01-10 2:19 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu, stable
In-Reply-To: <1483669846-106719-1-git-send-email-wenzhuo.lu@intel.com>
The function name ixgbe_vmdq_mode_check is not right.
This function checks if Virtualization Technology is
enabled. It's for both VMDq and IOV.
Others may be misled by the current name.
Fixes: fe3a45fd4104 ("ixgbe: add VMDq support")
CC: stable@dpdk.org
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
v2:
- rebased the patch based on next-net.
drivers/net/ixgbe/ixgbe_ethdev.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 3bf9d32..b7ddd4f 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4405,14 +4405,14 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
}
static int
-ixgbe_vmdq_mode_check(struct ixgbe_hw *hw)
+ixgbe_vt_check(struct ixgbe_hw *hw)
{
uint32_t reg_val;
- /* we only need to do this if VMDq is enabled */
+ /* if Virtualization Technology is enabled */
reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
- PMD_INIT_LOG(ERR, "VMDq must be enabled for this setting");
+ PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
return -1;
}
@@ -4792,7 +4792,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
" on 82599 hardware and newer");
return -ENOTSUP;
}
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
val = ixgbe_convert_vm_rx_mask_to_val(rx_mask, val);
@@ -4833,7 +4833,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
/* for vf >= 32, set bit in PFVFRE[1], otherwise PFVFRE[0] */
@@ -4883,7 +4883,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
return -EINVAL;
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
/* for vf >= 32, set bit in PFVFTE[1], otherwise PFVFTE[0] */
@@ -4929,7 +4929,7 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
return -EINVAL;
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
for (vf_idx = 0; vf_idx < 64; vf_idx++) {
@@ -5060,7 +5060,7 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
uint8_t mirror_type = 0;
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
if (rule_id >= IXGBE_MAX_MIRROR_RULES)
@@ -5181,7 +5181,7 @@ int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
struct ixgbe_mirror_info *mr_info =
(IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
- if (ixgbe_vmdq_mode_check(hw) < 0)
+ if (ixgbe_vt_check(hw) < 0)
return -ENOTSUP;
memset(&mr_info->mr_conf[rule_id], 0,
--
1.9.3
^ permalink raw reply related
* MSI-X vector #1 seems to be stalled sometimes after VF reset (ixgbe)
From: Ruslan Nikolaev @ 2017-01-10 2:42 UTC (permalink / raw)
To: dev
Attached are 2 patches, and the discussion below is related to the slightly modified version of the dpdk 16.07 library: interrupts_excerpt.patch and dpdk_vfreset.patch
1. We use a single-shot interrupt mechanism for the RX queue (vector #1, intr_handle.efds[0]file descriptor).
When we receive first interrupt, we start a polling thread. When the polling thread becomes idle again, we enable interrupts.
(to enable interrupts, we use rte_eth_dev_rx_intr_enable, queue_id = 0)
2. We enable interrupts right away for mailbox, reset adapter notifications (vector #0, intr_handle.fd file descriptor)
(to enable interrupts, we use rte_eth_dev_rx_intr_enable, queue_id = UINT16_MAX which we reserved for non-RX interrupts)
3. Changes related to interrupt setup and enabling/disabling are in interrupt_excerpt.patch
Changes: Seems like writing to the register already implies OR-semantic in interrupt enabling, so it does not seem be necessary to read previous value of the register (especially that now we have to have 2 vectors and want to avoid any race condition between reading and writing the register). Also, rte_intr_enable is going to write the same configuration to VFIO which does not seem to be necessary. Could you confirm and/or clarify that?
For disabling interrupt, it seems we have to use a different register.
4. Changes related to resetting devices are in dpdk_vfreset.patch
We used an unofficial patch from http://dpdk.org/dev/patchwork/patch/14009/ as the model. The patch is doing pretty the same thing but just maintains a state machine for our convenience, so that we can have a loop outside the reset function.
5. We see an intermittent stall of interrupt vector #1 when links are toggled. It does not always happen but only intermittently. Vector #0 still seems to work fine because we are able to get mailbox interrupts (when the adapter is reset).
Our current suspicion is that it may have something to do to the reset adapter handling in the unofficial patch (which, in turns, relies on dev_stop/dev_start functions). It appears that vector #1 (RX) interrupts are stalled intermittently only after the adapter reset takes place.
Please give your advice / suggestions.
^ permalink raw reply
* Re: MSI-X vector #1 seems to be stalled sometimes after VF reset (ixgbe)
From: Ruslan Nikolaev @ 2017-01-10 2:47 UTC (permalink / raw)
To: dev
In-Reply-To: <56D73D38-A0F0-4289-BEF2-A46620461E94@purestorage.com>
interrupts_excerpts.patch:
drivers/net/ixgbe/ixgbe_ethdev.c
eth_ixgbevf_dev_init:
@@ -1462,8 +1467,9 @@
rte_intr_callback_register(&pci_dev->intr_handle,
ixgbevf_dev_interrupt_handler,
(void *)eth_dev);
- rte_intr_enable(&pci_dev->intr_handle);
- ixgbevf_intr_enable(hw);
+
+ /* XXX: not enabling interrupts here since they are enabled in dev_start anyway,
+ and we do not have correct number of interrupt vectors here yet. */
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
eth_dev->data->port_id, pci_dev->id.vendor_id,
ixgbevf_dev_start:
@@ -4168,7 +4174,7 @@
/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
- intr_vector = dev->data->nb_rx_queues;
+ intr_vector = 1;
if (rte_intr_efd_enable(intr_handle, intr_vector))
return -1;
}
@@ -4789,31 +4801,27 @@
static int
ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
{
- uint32_t mask;
+ /* use vector #0 for mailbox interrupts and vector #1 for all RX queues */
+ uint8_t idx = (queue_id < IXGBE_MAX_QUEUE_NUM_PER_VF);
+ uint32_t mask = 1U << idx;
struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
- mask |= (1 << IXGBE_MISC_VEC_ID);
- RTE_SET_USED(queue_id);
IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
- rte_intr_enable(&dev->pci_dev->intr_handle);
-
return 0;
}
static int
ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
{
- uint32_t mask;
+ /* use vector #0 for mailbox interrupts and vector #1 for all RX queues */
+ uint8_t idx = (queue_id < IXGBE_MAX_QUEUE_NUM_PER_VF);
+ uint32_t mask = 1U << idx;
struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
- mask &= ~(1 << IXGBE_MISC_VEC_ID);
- RTE_SET_USED(queue_id);
- IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
+ IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, mask);
return 0;
}
ixgbevf_configure_msix:
@@ -4948,10 +4956,9 @@
struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
uint32_t q_idx;
- uint32_t vector_idx = IXGBE_MISC_VEC_ID;
/* Configure VF other cause ivar */
- ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
+ ixgbevf_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
/* won't configure msix register if no mapping is done
* between intr vector and event fd.
@@ -4961,11 +4968,9 @@
/* Configure all RX queues of VF */
for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
- /* Force all queue use vector 0,
- * as IXGBE_VF_MAXMSIVECOTR = 1
- */
- ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
- intr_handle->intr_vec[q_idx] = vector_idx;
+ /* Force all queues to use vector 1 */
+ ixgbevf_set_ivar_map(hw, 0, q_idx, IXGBE_RX_VEC_START);
+ intr_handle->intr_vec[q_idx] = IXGBE_RX_VEC_START;
}
}
^ permalink raw reply
* Re: MSI-X vector #1 seems to be stalled sometimes after VF reset (ixgbe)
From: Ruslan Nikolaev @ 2017-01-10 2:48 UTC (permalink / raw)
To: dev
In-Reply-To: <56D73D38-A0F0-4289-BEF2-A46620461E94@purestorage.com>
dpdk_vfreset.patch:
diff -urN dpdk-16.07/doc/guides/nics/overview.rst dpdk-16.07-new/doc/guides/nics/overview.rst
--- dpdk-16.07/doc/guides/nics/overview.rst 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/doc/guides/nics/overview.rst 2016-12-15 17:32:27.436425563 -0800
@@ -89,6 +89,7 @@
Speed capabilities
Link status Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Link status event Y Y Y Y Y Y Y Y Y Y Y Y Y Y
+ Link reset Y Y Y Y Y
Queue status event Y
Rx interrupt Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Queue start/stop Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
diff -urN dpdk-16.07/doc/guides/rel_notes/release_16_07.rst dpdk-16.07-new/doc/guides/rel_notes/release_16_07.rst
--- dpdk-16.07/doc/guides/rel_notes/release_16_07.rst 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/doc/guides/rel_notes/release_16_07.rst 2016-12-15 17:32:27.436425563 -0800
@@ -15,6 +15,15 @@
firefox build/doc/html/guides/rel_notes/release_16_07.html
+* **Added device reset support for ixgbe VF.**
+
+ Added the device reset API. APP can call this API to reset the VF port
+ when it's not working.
+ Based on the mailbox interruption support, when VF reseives the control
+ message from PF, it means the PF link state changes, VF uses the reset
+ callback in the message handler to notice the APP. APP need call the device
+ reset API to reset the VF port.
+
New Features
------------
diff -urN dpdk-16.07/drivers/net/ixgbe/ixgbe_ethdev.c dpdk-16.07-new/drivers/net/ixgbe/ixgbe_ethdev.c
--- dpdk-16.07/drivers/net/ixgbe/ixgbe_ethdev.c 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/drivers/net/ixgbe/ixgbe_ethdev.c 2016-12-15 17:47:51.212425563 -0800
@@ -388,6 +388,10 @@
static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel);
+static int ixgbevf_dev_reset(struct rte_eth_dev *dev,
+ struct rte_eth_reset_state *state,
+ uint32_t nonce);
+
/*
* Define VF Stats MACRO for Non "cleared on read" register
*/
@@ -593,6 +597,7 @@
.reta_query = ixgbe_dev_rss_reta_query,
.rss_hash_update = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
+ .dev_reset = ixgbevf_dev_reset,
};
/* store statistics names and its offset in stats structure */
@@ -4157,7 +4162,9 @@
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);
- ixgbevf_dev_rxtx_start(dev);
+ err = ixgbevf_dev_rxtx_start(dev);
+ if (err)
+ return err;
/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -7305,6 +7312,75 @@
}
static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev, struct rte_eth_reset_state *state, uint32_t nonce)
+{
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int diag = 0;
+ uint32_t vteiam;
+ struct timespec ts;
+
+ /* STATES: [0] initial, [2] stopped, and [1] started (reset complete). */
+ if (state->state <= 1)
+ {
+ /* Nothing needs to be done if reset is complete and the nonce is the same. */
+ if (state->state == 1 && state->nonce == nonce)
+ return 0;
+
+ state->nonce = nonce;
+ state->state = 2;
+ /* Performance VF reset. */
+ dev->data->dev_started = 0;
+ ixgbevf_dev_stop(dev);
+ if (dev->data->dev_conf.intr_conf.lsc == 0)
+ diag = ixgbe_dev_link_update(dev, 0);
+ if (diag) {
+ PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+ "Failed to update link.");
+ }
+ clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
+ state->time = ts.tv_sec;
+ return 1;
+ }
+
+ /* Delay of 1s */
+ clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
+ if (ts.tv_sec - state->time < 1) {
+ return 1;
+ }
+
+ state->state = 0;
+ diag = ixgbevf_dev_start(dev);
+ /* If fail to start the device, need to stop/start it again. */
+ if (diag) {
+ PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+ "Failed to start device.");
+ return 1;
+ }
+ dev->data->dev_started = 1;
+ ixgbevf_dev_stats_reset(dev);
+ if (dev->data->dev_conf.intr_conf.lsc == 0)
+ diag = ixgbe_dev_link_update(dev, 0);
+ if (diag) {
+ PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+ "Failed to update link.");
+ }
+
+ /**
+ * When the PF link is down, there has chance
+ * that VF cannot operate its registers. Will
+ * check if the registers is written
+ * successfully. If not, repeat stop/start until
+ * the PF link is up, in other words, until the
+ * registers can be written.
+ */
+ vteiam = IXGBE_READ_REG(hw, IXGBE_VTEIAM);
+ /* Reference ixgbevf_intr_enable when checking. */
+ state->state = (vteiam == IXGBE_VF_IRQ_ENABLE_MASK && state->nonce == nonce);
+ /* The state is going to be 1 if successful and 0 -- otherwise. */
+ return !state->state;
+}
+
+static int
ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
{
uint32_t eicr;
diff -urN dpdk-16.07/drivers/net/ixgbe/ixgbe_ethdev.h dpdk-16.07-new/drivers/net/ixgbe/ixgbe_ethdev.h
--- dpdk-16.07/drivers/net/ixgbe/ixgbe_ethdev.h 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/drivers/net/ixgbe/ixgbe_ethdev.h 2016-12-15 17:32:27.436425563 -0800
@@ -377,7 +377,7 @@
void ixgbevf_dev_tx_init(struct rte_eth_dev *dev);
-void ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+int ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
uint16_t ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
diff -urN dpdk-16.07/drivers/net/ixgbe/ixgbe_rxtx.c dpdk-16.07-new/drivers/net/ixgbe/ixgbe_rxtx.c
--- dpdk-16.07/drivers/net/ixgbe/ixgbe_rxtx.c 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/drivers/net/ixgbe/ixgbe_rxtx.c 2016-12-15 17:32:27.440425563 -0800
@@ -5247,7 +5247,7 @@
/*
* [VF] Start Transmit and Receive Units.
*/
-void __attribute__((cold))
+int __attribute__((cold))
ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
{
struct ixgbe_hw *hw;
@@ -5283,8 +5283,10 @@
rte_delay_ms(1);
txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
} while (--poll_ms && !(txdctl & IXGBE_TXDCTL_ENABLE));
- if (!poll_ms)
+ if (!poll_ms) {
PMD_INIT_LOG(ERR, "Could not enable Tx Queue %d", i);
+ return -1;
+ }
}
for (i = 0; i < dev->data->nb_rx_queues; i++) {
@@ -5300,12 +5302,16 @@
rte_delay_ms(1);
rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
} while (--poll_ms && !(rxdctl & IXGBE_RXDCTL_ENABLE));
- if (!poll_ms)
+ if (!poll_ms) {
PMD_INIT_LOG(ERR, "Could not enable Rx Queue %d", i);
+ return -1;
+ }
rte_wmb();
IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), rxq->nb_rx_desc - 1);
}
+
+ return 0;
}
/* Stubs needed for linkage when CONFIG_RTE_IXGBE_INC_VECTOR is set to 'n' */
diff -urN dpdk-16.07/lib/librte_ether/rte_ethdev.c dpdk-16.07-new/lib/librte_ether/rte_ethdev.c
--- dpdk-16.07/lib/librte_ether/rte_ethdev.c 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/lib/librte_ether/rte_ethdev.c 2016-12-15 17:32:27.440425563 -0800
@@ -3446,3 +3446,20 @@
-ENOTSUP);
return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
}
+
+int
+rte_eth_dev_reset(uint8_t port_id, struct rte_eth_reset_state *state, uint32_t nonce)
+{
+ struct rte_eth_dev *dev;
+ int diag;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+ dev = &rte_eth_devices[port_id];
+
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
+
+ diag = (*dev->dev_ops->dev_reset)(dev, state, nonce);
+
+ return diag;
+}
diff -urN dpdk-16.07/lib/librte_ether/rte_ethdev.h dpdk-16.07-new/lib/librte_ether/rte_ethdev.h
--- dpdk-16.07/lib/librte_ether/rte_ethdev.h 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/lib/librte_ether/rte_ethdev.h 2016-12-15 17:40:44.936425563 -0800
@@ -980,6 +980,15 @@
};
/**
+ * A structure to maintain reset state.
+ */
+struct rte_eth_reset_state {
+ time_t time;
+ uint32_t nonce;
+ uint8_t state;
+};
+
+/**
* RX/TX queue states
*/
#define RTE_ETH_QUEUE_STATE_STOPPED 0
@@ -1347,6 +1356,11 @@
uint8_t en);
/**< @internal enable/disable the l2 tunnel offload functions */
+typedef int (*eth_dev_reset_t)(struct rte_eth_dev *dev,
+ struct rte_eth_reset_state *state,
+ uint32_t nonce);
+/**< @internal Function used to reset a configured Ethernet device. */
+
#ifdef RTE_NIC_BYPASS
enum {
@@ -1537,6 +1551,8 @@
eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
/** Enable/disable l2 tunnel offload functions */
eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
+ /** Reset device. */
+ eth_dev_reset_t dev_reset;
};
/**
@@ -4368,6 +4384,30 @@
int
rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);
+/**
+ * Reset an ethernet device when it's not working. One scenario is, after PF
+ * port is down and up, the related VF port should be reset.
+ * The API will stop the port, clear the rx/tx queues, re-setup the rx/tx
+ * queues, restart the port.
+ * Before calling this API, APP should stop the rx/tx. When tx is being stopped,
+ * APP can drop the packets and release the buffer instead of sending them.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param state
+ * The reset state (must be initialized to 0 initially).
+ * @param nonce
+ * A 32-bit number indicating the current reset attempt.
+ *
+ * @return
+ * - (0) if successful.
+ * - (1) needs to be called again.
+ * - (-ENODEV) if port identifier is invalid.
+ * - (-ENOTSUP) if hardware doesn't support this function.
+ */
+int
+rte_eth_dev_reset(uint8_t port_id, struct rte_eth_reset_state *state, uint32_t nonce);
+
#ifdef __cplusplus
}
#endif
diff -urN dpdk-16.07/lib/librte_ether/rte_ether_version.map dpdk-16.07-new/lib/librte_ether/rte_ether_version.map
--- dpdk-16.07/lib/librte_ether/rte_ether_version.map 2016-07-28 11:48:41.000000000 -0700
+++ dpdk-16.07-new/lib/librte_ether/rte_ether_version.map 2016-12-15 17:32:27.440425563 -0800
@@ -138,4 +138,5 @@
rte_eth_dev_get_name_by_port;
rte_eth_dev_get_port_by_name;
rte_eth_xstats_get_names;
+ rte_eth_dev_reset;
} DPDK_16.04;
^ permalink raw reply
* Re: [PATCH v5 01/12] eal/bus: introduce bus abstraction
From: Shreyansh Jain @ 2017-01-10 4:07 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: david.marchand, dev, thomas.monjalon
In-Reply-To: <f2e2cc0c-a797-0143-b53a-fda6bed9dccf@intel.com>
Hello Ferruh,
On Monday 09 January 2017 08:52 PM, Ferruh Yigit wrote:
> On 12/26/2016 1:23 PM, Shreyansh Jain wrote:
>
> <...>
>
>> +
>> +DPDK_17.02 {
>> + global:
>> +
>> + rte_bus_list;
>> + rte_eal_bus_add_device;
>> + rte_eal_bus_add_driver;
>> + rte_eal_bus_get;
>> + rte_eal_bus_dump;
>> + rte_eal_bus_register;
>
>> + rte_eal_bus_insert_device;
>
> This function added in patch 3/12, it can be good to add this function
> into .map file in that patch.
Yes, I caught this while rebasing for v6. In fact, now this function
itself has been removed.
Nevertheless, thanks for reviewing.
>
> <...>
>
>
-
Shreyansh
^ permalink raw reply
* Re: [PATCH v5 11/12] drivers: update PMDs to use rte_driver probe and remove
From: Shreyansh Jain @ 2017-01-10 4:09 UTC (permalink / raw)
To: Ferruh Yigit, david.marchand; +Cc: dev, thomas.monjalon
In-Reply-To: <03401dd4-5d78-6ad2-e199-c076495e186d@intel.com>
On Monday 09 January 2017 09:48 PM, Ferruh Yigit wrote:
> On 1/9/2017 3:19 PM, Ferruh Yigit wrote:
>> On 12/26/2016 1:24 PM, Shreyansh Jain wrote:
>>> These callbacks now act as first layer of PCI interfaces from the Bus.
>>> Bus probe would enter the PMDs through the rte_driver->probe/remove
>>> callbacks, falling to rte_xxx_driver->probe/remove (Currently, all the
>>> drivers are rte_pci_driver).
>>>
>>> This patch also changes QAT which is the only crypto PMD based on PCI.
>>> All others would be changed in a separate patch focused on VDEV.
>>>
>>> Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
>>> ---
> <...>
>>>
>>> diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c
>>> index 1e7ee61..bc1a9c6 100644
>>> --- a/drivers/crypto/qat/rte_qat_cryptodev.c
>>> +++ b/drivers/crypto/qat/rte_qat_cryptodev.c
>>> @@ -120,6 +120,10 @@ crypto_qat_dev_init(__attribute__((unused)) struct rte_cryptodev_driver *crypto_
>>>
>>> static struct rte_cryptodev_driver rte_qat_pmd = {
>>> .pci_drv = {
>>> + .driver = {
>>> + .probe = rte_eal_pci_probe,
>>> + .remove = rte_eal_pci_remove,
>>> + },
>>
>> Since this part is common for all PCI drivers, why not make this part of
>> RTE_PMD_REGISTER_PCI macro?
>>
>
> I have seen your comment [1] which looks like better idea.
Thanks.
And, actually, it is mostly Thomas's idea :)
>
> providing a rte_bus->probe(),
>
> and rte_eal_bus_probe() calls rte_bus->probe()
>
> for pci devices, rte_bus->probe = rte_eal_pci_probe ..
>
>
> [1]
> http://dpdk.org/ml/archives/dev/2017-January/054125.html
>
> Thanks,
> ferruh
>
^ permalink raw reply
* Re: [PATCH v3 00/33] NXP DPAA2 PMD
From: Shreyansh Jain @ 2017-01-10 4:19 UTC (permalink / raw)
To: Ferruh Yigit, dev
Cc: thomas.monjalon, bruce.richardson, john.mcnamara, jerin.jacob
In-Reply-To: <19bb2147-08b8-9163-bb17-2072986ae67a@intel.com>
On Monday 09 January 2017 11:12 PM, Ferruh Yigit wrote:
> On 12/29/2016 5:16 AM, Shreyansh Jain wrote:
>> ** Sending v3 on behalf of Hemant Agrawal **
>>
>
> <...>
>
> Hi,
>
> Getting compile error for shared library [1] build.
> Not investigated, copying here.
>
> Thanks,
> ferruh
>
>
> [1]
> == Build drivers/net/dpaa2
> LD librte_pmd_dpaa2.so.1.1
> /usr/bin/ld: cannot find -lrte_pmd_dpaa2_qbman
> /usr/bin/ld: cannot find -lrte_pmd_dpaa2_pool
>
I think this would be coming for parallel builds. Serial build for
shared library is working as far as I know.
For parallel, somehow the rte_pmd_dpaa2_qbman dependency for net/dpaa2
is not getting clearly defined because of which net/dpaa2 linking is
attempted even before rte_pmd_dpaa2_qbman is ready.
I found that this might be because of the way scripts/depdirs-rule.sh
forms the common-est directory. It works fine when dependent libraries
are within lib/*, but when a drivers/net is dependent on driver/common
or driver/bus, it somehow isn't working.
I am still investigating this.
-
Shreyansh
^ permalink raw reply
* Why MLX4 can only generate 6Mpp/s (64B pkt) by one core?
From: Royce Niu @ 2017-01-10 4:51 UTC (permalink / raw)
To: dev
Dear all,
My Mellanox 3 Pro can only generate packet at maximum of 6Mpp/s (64B) by
one core. This is too slow for a 40Gbps port. Could anyone give me a hint
please?
Configuration:
Followed: http://dpdk.org/doc/guides/nics/mlx4.html
1. install MLNX_OFED_LINUX-3.4-2.0.0.0
2. Added CONFIG_RTE_LIBRTE_MLX4_PMD=y in .config
3. make DPDK 16.07.2
4. Closed Dell S6000 swith flow control (both rx,tx)
5. Made sure all ports are in 40GBE mode
With my own pkt-gen and DPDK-pktgen, both generate at 6Mpps of 64B pkt by
one core, which is so slow, since I can generate 14Mpps via an Intel X520
10G interface.
Thanks.
--
Regards,
Royce
^ permalink raw reply
* Re: [PATCH v2 02/18] net/ixgbe: store flow director filter
From: Zhao1, Wei @ 2017-01-10 5:30 UTC (permalink / raw)
To: Yigit, Ferruh, dev@dpdk.org; +Cc: Lu, Wenzhuo
In-Reply-To: <0505090d-e126-12d5-75e6-2a0498cec4bf@intel.com>
Hi, yigit
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, January 7, 2017 12:31 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 02/18] net/ixgbe: store flow director filter
>
> On 12/30/2016 7:52 AM, Wei Zhao wrote:
> > Add support for storing flow director filter in SW.
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > ---
> >
> > v2:
> > --add a fdir initialization function in device start process
> > ---
> <...>
> > @@ -1276,6 +1278,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
> >
> > /* initialize SYN filter */
> > filter_info->syn_info = 0;
> > + /* initialize flow director filter list & hash */
> > + ixgbe_fdir_filter_init(eth_dev);
> > +
> > return 0;
> > }
> >
> > @@ -1284,6 +1289,9 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev
> > *eth_dev) {
> > struct rte_pci_device *pci_dev;
> > struct ixgbe_hw *hw;
> > + struct ixgbe_hw_fdir_info *fdir_info =
> > + IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data-
> >dev_private);
> > + struct ixgbe_fdir_filter *fdir_filter;
> >
> > PMD_INIT_FUNC_TRACE();
> >
> > @@ -1317,9 +1325,56 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev
> *eth_dev)
> > rte_free(eth_dev->data->hash_mac_addrs);
> > eth_dev->data->hash_mac_addrs = NULL;
> >
> > + /* remove all the fdir filters & hash */
> > + if (fdir_info->hash_map)
> > + rte_free(fdir_info->hash_map);
> > + if (fdir_info->hash_handle)
> > + rte_hash_free(fdir_info->hash_handle);
> > +
> > + while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
> > + TAILQ_REMOVE(&fdir_info->fdir_list,
> > + fdir_filter,
> > + entries);
> > + rte_free(fdir_filter);
> > + }
> > +
>
> What do you think extracting these into a function as done in init() ?
>
> <...>
Ok , I will do as your suggestion.
^ permalink raw reply
* Re: [PATCH v2 01/18] net/ixgbe: store SYN filter
From: Zhao1, Wei @ 2017-01-10 5:33 UTC (permalink / raw)
To: Yigit, Ferruh, dev@dpdk.org; +Cc: Lu, Wenzhuo
In-Reply-To: <8bb0cda8-fafc-d906-4708-bfbb28b55a91@intel.com>
Hi, yigit
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, January 7, 2017 12:29 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 01/18] net/ixgbe: store SYN filter
>
> On 12/30/2016 7:52 AM, Wei Zhao wrote:
> > Add support for storing SYN filter in SW.
>
> I think you have mentioned in previous review that you will update this to
> "TCP SYN", I would like to remind in case it is missed.
>
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > ---
> >
> > v2:
> > --synqf assignment location change
> > ---
> <...>
There is something wrong when I update code in v2.
I PROMISE it will be changed in v3.
^ permalink raw reply
* Re: [PATCH v2 13/18] net/ixgbe: parse TCP SYN filter
From: Zhao1, Wei @ 2017-01-10 5:46 UTC (permalink / raw)
To: Yigit, Ferruh, dev@dpdk.org; +Cc: Lu, Wenzhuo
In-Reply-To: <8c0dd569-43e5-8b8c-d411-aef2be616e03@intel.com>
Hi, Yigit
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, January 7, 2017 1:20 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 13/18] net/ixgbe: parse TCP SYN filter
>
> On 12/30/2016 7:53 AM, Wei Zhao wrote:
> > check if the rule is a TCP SYN rule, and get the SYN info.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> >
> > ---
> >
> > v2:add new error set function
> > ---
>
> <...>
>
> > +static int
> > +ixgbe_parse_syn_filter(const struct rte_flow_attr *attr,
> > + const struct rte_flow_item pattern[],
> > + const struct rte_flow_action actions[],
> > + struct rte_eth_syn_filter *filter,
> > + struct rte_flow_error *error) {
> > + int ret;
> > +
> > + ret = cons_parse_syn_filter(attr, pattern,
> > + actions, filter, error);
> > +
>
> > + if (ret)
> > + return ret;
> > +
> > + return 0;
>
> "return ret;" will do the same.
> Or remove ret completely perhaps.
>
> > +}
> > +
> <...>
Yes, "return ret;" may be more appropriate.
^ permalink raw reply
* Re: [PATCH v2 16/18] net/ixgbe: create consistent filter
From: Zhao1, Wei @ 2017-01-10 5:50 UTC (permalink / raw)
To: Yigit, Ferruh, dev@dpdk.org; +Cc: Lu, Wenzhuo
In-Reply-To: <881b7663-a7d6-d0e8-4d94-f83343ad9c76@intel.com>
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, January 7, 2017 1:27 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2 16/18] net/ixgbe: create consistent filter
>
> On 12/30/2016 7:53 AM, Wei Zhao wrote:
> > This patch adds a function to create the flow directory filter.
> >
> > Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> >
> > ---
> >
> > v2:
> > --add new error set function
> > ---
>
> <...>
>
> >
> > +struct ixgbe_flow {
> > + enum rte_filter_type filter_type;
> > + void *rule;
> > +};
>
> It is possible to rename this struct to rte_flow, to prevent casting.
> Although functionally there is no difference.
Ok, I will do that in v3
>
> > +
> > /*
> > * Structure to store private data for each driver instance (for each port).
> > */
> >
^ permalink raw reply
* Re: [PATCH v2 5/7] net/virtio_user: add vhost kernel support
From: Tan, Jianfeng @ 2017-01-10 6:11 UTC (permalink / raw)
To: Jason Wang, dev; +Cc: yuanhan.liu, ferruh.yigit, cunming.liang
In-Reply-To: <46af618f-c01b-3571-78fc-12d10859a4a1@redhat.com>
Hi Jason,
On 1/9/2017 12:39 PM, Jason Wang wrote:
>
>
> On 2016年12月23日 15:14, Jianfeng Tan wrote:
>> This patch add support vhost kernel as the backend for virtio_user.
>> Three main hook functions are added:
>> - vhost_kernel_setup() to open char device, each vq pair needs one
>> vhostfd;
>> - vhost_kernel_ioctl() to communicate control messages with vhost
>> kernel module;
>> - vhost_kernel_enable_queue_pair() to open tap device and set it
>> as the backend of corresonding vhost fd (that is to say, vq pair).
>>
>> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
>> ---
>>
[...]
>> +/* TUNSETIFF ifr flags */
>> +#define IFF_TAP 0x0002
>> +#define IFF_NO_PI 0x1000
>> +#define IFF_ONE_QUEUE 0x2000
>> +#define IFF_VNET_HDR 0x4000
>> +#define IFF_MULTI_QUEUE 0x0100
>> +#define IFF_ATTACH_QUEUE 0x0200
>> +#define IFF_DETACH_QUEUE 0x0400
>
> Do we really want to duplicate those things which has been exposed by
> uapi here?
You mean those defined in <linux/if_tun.h>? Redefine those common
macros, or include standard header file, with respective pros and cons.
DPDK prefers the redefinition way as far as I understand, doesn't it?
>
>> +
>> +/* Constants */
>> +#define TUN_DEF_SNDBUF (1ull << 20)
>> +#define PATH_NET_TUN "/dev/net/tun"
>> +#define VHOST_KERNEL_MAX_REGIONS 64
>
> Unfortunate not a constant any more since c9ce42f72fd0 vhost: add
> max_mem_regions module parameter.
Yes, I was considering to ignore this in the initial release. But it's
not a big effort, I'll try to fix it in latest version.
>
>> +
>> +static uint64_t vhost_req_user_to_kernel[] = {
>> + [VHOST_USER_SET_OWNER] = VHOST_SET_OWNER,
>> + [VHOST_USER_RESET_OWNER] = VHOST_RESET_OWNER,
>> + [VHOST_USER_SET_FEATURES] = VHOST_SET_FEATURES,
>> + [VHOST_USER_GET_FEATURES] = VHOST_GET_FEATURES,
>> + [VHOST_USER_SET_VRING_CALL] = VHOST_SET_VRING_CALL,
>> + [VHOST_USER_SET_VRING_NUM] = VHOST_SET_VRING_NUM,
>> + [VHOST_USER_SET_VRING_BASE] = VHOST_SET_VRING_BASE,
>> + [VHOST_USER_GET_VRING_BASE] = VHOST_GET_VRING_BASE,
>> + [VHOST_USER_SET_VRING_ADDR] = VHOST_SET_VRING_ADDR,
>> + [VHOST_USER_SET_VRING_KICK] = VHOST_SET_VRING_KICK,
>> + [VHOST_USER_SET_MEM_TABLE] = VHOST_SET_MEM_TABLE,
>> +};
>> +
>> +/* By default, vhost kernel module allows 64 regions, but DPDK allows
>> + * 256 segments. As a relief, below function merges those virtually
>> + * adjacent memsegs into one region.
>> + */
>> +static struct vhost_memory_kernel *
>> +prepare_vhost_memory_kernel(void)
>> +{
>> + uint32_t i, j, k = 0;
>> + struct rte_memseg *seg;
>> + struct vhost_memory_region *mr;
>> + struct vhost_memory_kernel *vm;
>> +
>> + vm = malloc(sizeof(struct vhost_memory_kernel) +
>> + VHOST_KERNEL_MAX_REGIONS *
>> + sizeof(struct vhost_memory_region));
>> +
>> + for (i = 0; i < RTE_MAX_MEMSEG; ++i) {
>> + seg = &rte_eal_get_configuration()->mem_config->memseg[i];
>> + if (!seg->addr)
>> + break;
>
> If we're sure the number of regions is less than 64(or the module
> parameter read from /sys), can we avoid the iteration here?
The "if" statement under the "for" statement can save us from all
RTE_MAX_MEMSEG iteration.
>
>> +
>> + int new_region = 1;
>> +
>> + for (j = 0; j < k; ++j) {
>> + mr = &vm->regions[j];
>> +
>> + if (mr->userspace_addr + mr->memory_size ==
>> + (uint64_t)seg->addr) {
>> + mr->memory_size += seg->len;
>> + new_region = 0;
>> + break;
>> + }
>> +
>> + if ((uint64_t)seg->addr + seg->len ==
>> + mr->userspace_addr) {
>> + mr->guest_phys_addr = (uint64_t)seg->addr;
>> + mr->userspace_addr = (uint64_t)seg->addr;
>> + mr->memory_size += seg->len;
>> + new_region = 0;
>> + break;
>> + }
>> + }
>> +
>> + if (new_region == 0)
>> + continue;
>> +
>> + mr = &vm->regions[k++];
>> + mr->guest_phys_addr = (uint64_t)seg->addr; /* use vaddr
>> here! */
>> + mr->userspace_addr = (uint64_t)seg->addr;
>> + mr->memory_size = seg->len;
>> + mr->mmap_offset = 0;
>> +
>> + if (k >= VHOST_KERNEL_MAX_REGIONS) {
>> + free(vm);
>> + return NULL;
>> + }
>> + }
>> +
>> + vm->nregions = k;
>> + vm->padding = 0;
>> + return vm;
>> +}
>> +
>> +static int
>> +vhost_kernel_ioctl(struct virtio_user_dev *dev,
>> + enum vhost_user_request req,
>> + void *arg)
>> +{
>> + int i, ret = -1;
>> + uint64_t req_kernel;
>> + struct vhost_memory_kernel *vm = NULL;
>> +
>> + req_kernel = vhost_req_user_to_kernel[req];
>> +
>> + if (req_kernel == VHOST_SET_MEM_TABLE) {
>> + vm = prepare_vhost_memory_kernel();
>> + if (!vm)
>> + return -1;
>> + arg = (void *)vm;
>> + }
>> +
>> + /* Does not work when VIRTIO_F_IOMMU_PLATFORM now, why? */
>
> I think the reason is when VIRTIO_F_IOMMU_PLATFORM is negotiated, all
> address should be iova instead of gpa.
>
Yes, I agree. As we don't have to do memory protection in a single
process, so it's completely useless here, right?
>> + if (req_kernel == VHOST_SET_FEATURES)
>> + *(uint64_t *)arg &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);
>> +
>> + for (i = 0; i < VHOST_KERNEL_MAX_QUEUES; ++i) {
>> + if (dev->vhostfds[i] < 0)
>> + continue;
>> +
[...]
>> + if (!enable) {
>> + if (dev->tapfds[pair_idx]) {
>> + close(dev->tapfds[pair_idx]);
>> + dev->tapfds[pair_idx] = -1;
>> + }
>> + return vhost_kernel_set_backend(vhostfd, -1);
>
> If this is used to for thing like ethtool -L in guest, we should use
> TUNSETQUEUE here.
Oops, I was missing this ioctl operation. Let me fix it in next version.
>
>> + } else if (dev->tapfds[pair_idx] >= 0) {
>> + return 0;
>> + }
>> +
>> + if ((dev->features & (1ULL << VIRTIO_NET_F_MRG_RXBUF)) ||
>> + (dev->features & (1ULL << VIRTIO_F_VERSION_1)))
>> + hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf);
>> + else
>> + hdr_size = sizeof(struct virtio_net_hdr);
>> +
>> + /* TODO:
>> + * 1. verify we can get/set vnet_hdr_len, tap_probe_vnet_hdr_len
>> + * 2. get number of memory regions from vhost module parameter
>> + * max_mem_regions, supported in newer version linux kernel
>> + */
>> + tapfd = open(PATH_NET_TUN, O_RDWR);
>> + if (tapfd < 0) {
>> + PMD_DRV_LOG(ERR, "fail to open %s: %s",
>> + PATH_NET_TUN, strerror(errno));
>> + return -1;
>> + }
>> +
>> + /* Construct ifr */
>> + memset(&ifr, 0, sizeof(ifr));
>> + ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>> +
>> + if (ioctl(tapfd, TUNGETFEATURES, &features) == -1) {
>> + PMD_DRV_LOG(ERR, "TUNGETFEATURES failed: %s", strerror(errno));
>> + goto error;
>> + }
>> + if (features & IFF_ONE_QUEUE)
>> + ifr.ifr_flags |= IFF_ONE_QUEUE;
>> +
>> + /* Let tap instead of vhost-net handle vnet header, as the
>> latter does
>> + * not support offloading. And in this case, we should not set
>> feature
>> + * bit VHOST_NET_F_VIRTIO_NET_HDR.
>> + */
>> + if (features & IFF_VNET_HDR) {
>> + ifr.ifr_flags |= IFF_VNET_HDR;
>> + } else {
>> + PMD_DRV_LOG(ERR, "TAP does not support IFF_VNET_HDR");
>> + goto error;
>> + }
>> +
>> + if (dev->ifname)
>> + strncpy(ifr.ifr_name, dev->ifname, IFNAMSIZ);
>> + else
>> + strncpy(ifr.ifr_name, "tap%d", IFNAMSIZ);
>> + if (ioctl(tapfd, TUNSETIFF, (void *)&ifr) == -1) {
>> + PMD_DRV_LOG(ERR, "TUNSETIFF failed: %s", strerror(errno));
>> + goto error;
>> + }
>
> This requires CAP_NET_ADMIN, so we should really consider to accept a
> pre-created fd here.
It sounds like a future work for me. So far, all DPDK apps are running
in privileged mode (including CAP_NET_ADMIN?).
>
>> +
>> + fcntl(tapfd, F_SETFL, O_NONBLOCK);
>> +
>> + if (ioctl(tapfd, TUNSETVNETHDRSZ, &hdr_size) < 0) {
>> + PMD_DRV_LOG(ERR, "TUNSETVNETHDRSZ failed: %s",
>> strerror(errno));
>> + goto error;
>> + }
>> +
>> + if (ioctl(tapfd, TUNSETSNDBUF, &sndbuf) < 0) {
>> + PMD_DRV_LOG(ERR, "TUNSETSNDBUF failed: %s", strerror(errno));
>> + goto error;
>> + }
>
> Let's use INT_MAX as default here to survive from evil consumer here.
Oh yes, I will fix it.
Thanks,
Jianfeng
^ permalink raw reply
* Re: [PATCH 01/18] net/ixgbe: store SYN filter
From: Zhao1, Wei @ 2017-01-10 6:48 UTC (permalink / raw)
To: Yigit, Ferruh, dev@dpdk.org; +Cc: Lu, Wenzhuo
In-Reply-To: <6ec950b1-f4e2-7343-8ba1-60c849695205@intel.com>
Hi, yigit
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Saturday, January 7, 2017 12:26 AM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH 01/18] net/ixgbe: store SYN filter
>
> On 12/22/2016 9:48 AM, Zhao1, Wei wrote:
> > Hi, Yigit
> >
> >> -----Original Message-----
> >> From: Yigit, Ferruh
> >> Sent: Wednesday, December 21, 2016 12:56 AM
> >> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> >> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> >> Subject: Re: [dpdk-dev] [PATCH 01/18] net/ixgbe: store SYN filter
> >>
> >> On 12/2/2016 10:42 AM, Wei Zhao wrote:
> >>> From: wei zhao1 <wei.zhao1@intel.com>
> >>>
> >>> Add support for storing SYN filter in SW.
> >>
> >> Do you think does it makes more clear to refer as TCP SYN filter? Or
> >> SYN filter is clear enough?
> >>
> >
> > Ok, I will change to " TCP SYN filter " to make it more clear
> >
> >>>
> >>> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> >>> Signed-off-by: wei zhao1 <wei.zhao1@intel.com>
> >>
> >> Can you please update sign-off to your actual name?
> >>
> >
> > Ok, I will change to " Signed-off-by: Wei Zhao <wei.zhao1@intel.com>"
> >
> >>> ---
> >>> drivers/net/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
> >>> drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++
> >>> 2 files changed, 12 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> >>> b/drivers/net/ixgbe/ixgbe_ethdev.c
> >>> index edc9b22..7f10cca 100644
> >>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> >>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> >>> @@ -1287,6 +1287,8 @@ eth_ixgbe_dev_init(struct rte_eth_dev
> *eth_dev)
> >>> memset(filter_info->fivetuple_mask, 0,
> >>> sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
> >>>
> >>> + /* initialize SYN filter */
> >>> + filter_info->syn_info = 0;
> >>
> >> can it be an option to memset all filter_info? (and of course move
> >> list init after memset)
> >>
> >
> > Maybe, change to the following code?
> >
> > memset(filter_info, 0, sizeof(struct ixgbe_filter_info));
> > TAILQ_INIT(&filter_info->fivetuple_list);
> >
> > But that wiil mix /* initialize ether type filter */ and /* initialize
> > 5tuple filter list */ two process together, Because struct ixgbe_filter_info
> store two type info of ether and 5tuple.
>
> I see filter info consist of different filter types, but as far as I can see they are
> not used before this memset, so what is the problem of cleaning all struct?
>
> Currently memset a sub-set of struct, and assigns zero to other field explicitly,
> and rest remains undefined and unused. I am suggesting memset whole
> structure and get rid of zero assignment.
>
Ok, do as your suggestion in v3.
> > So, not to change ?
> >
> > struct ixgbe_filter_info {
> > uint8_t ethertype_mask; /* Bit mask for every used ethertype filter
> */
> > /* store used ethertype filters*/
> > struct ixgbe_ethertype_filter
> ethertype_filters[IXGBE_MAX_ETQF_FILTERS];
> > /* Bit mask for every used 5tuple filter */
> > uint32_t fivetuple_mask[IXGBE_5TUPLE_ARRAY_SIZE];
> > struct ixgbe_5tuple_filter_list fivetuple_list;
> > /* store the SYN filter info */
> > uint32_t syn_info;
> > };
> >
> >
> <...>
^ permalink raw reply
* [PATCH v8 09/25] net/i40e: fix VF reset flow
From: Wenzhuo Lu @ 2017-01-10 7:16 UTC (permalink / raw)
To: dev; +Cc: Qi Zhang, stable
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
From: Qi Zhang <qi.z.zhang@intel.com>
Add missing step during VF reset: PF should
set I40E_VFGEN_RSTAT to ACTIVE at end of the
VF reset operation or VF driver may not able
to detect that reset is already completed.
This patch also remove the unnecessary enum
for vfr state.
Fixes: 4861cde46116 ("i40e: new poll mode driver")
CC: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/net/i40e/i40e_pf.c | 6 ++++--
drivers/net/i40e/i40e_pf.h | 5 -----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5c58424..8a6733c 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -139,7 +139,7 @@
abs_vf_id = vf_id + hw->func_caps.vf_base_id;
/* Notify VF that we are in VFR progress */
- I40E_WRITE_REG(hw, I40E_VFGEN_RSTAT1(vf_id), I40E_PF_VFR_INPROGRESS);
+ I40E_WRITE_REG(hw, I40E_VFGEN_RSTAT1(vf_id), I40E_VFR_INPROGRESS);
/*
* If require a SW VF reset, a VFLR interrupt will be generated,
@@ -220,7 +220,7 @@
}
/* Reset done, Set COMPLETE flag and clear reset bit */
- I40E_WRITE_REG(hw, I40E_VFGEN_RSTAT1(vf_id), I40E_PF_VFR_COMPLETED);
+ I40E_WRITE_REG(hw, I40E_VFGEN_RSTAT1(vf_id), I40E_VFR_COMPLETED);
val = I40E_READ_REG(hw, I40E_VPGEN_VFRTRIG(vf_id));
val &= ~I40E_VPGEN_VFRTRIG_VFSWR_MASK;
I40E_WRITE_REG(hw, I40E_VPGEN_VFRTRIG(vf_id), val);
@@ -248,6 +248,8 @@
return -EFAULT;
}
+ I40E_WRITE_REG(hw, I40E_VFGEN_RSTAT1(vf_id), I40E_VFR_VFACTIVE);
+
return ret;
}
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index 47a9c34..b4c2287 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -48,11 +48,6 @@
#define I40E_DPDK_OFFSET 0x100
-enum i40e_pf_vfr_state {
- I40E_PF_VFR_INPROGRESS = 0,
- I40E_PF_VFR_COMPLETED = 1,
-};
-
/* DPDK pf driver specific command to VF */
enum i40e_virtchnl_ops_dpdk {
/*
--
1.9.3
^ permalink raw reply related
* [PATCH v8 12/25] net/i40e: fix VF MAC address assignment
From: Wenzhuo Lu @ 2017-01-10 7:16 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, stable
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
From: Ferruh Yigit <ferruh.yigit@intel.com>
If PF sets vf->mac_addr, in VF initialization hw->mac.addr will be set
to that same value. It is possible to check if PF set a MAC address or
not through the hw->mac.addr variable.
hw->mac.addr set by i40e_vf_parse_hw_config(), call stack is:
In PF side
i40e_pf_host_process_cmd_get_vf_resources()
eth_addr_copy(vf->mac_addr, vf_res->vsi_res[0].default_mac_address)
In VF sise
i40evf_init_vf()
i40evf_get_vf_resources()
i40e_vf_parse_hw_config()
memcpy(hw->mac.addr, vsi_res->default_mac_addr)
Updated code is after i40evf_get_vf_resources() and can benefit from
hw->mac.addr variable.
Fixes: 89e6b86384bb ("i40evf: rework MAC address validation")
CC: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
drivers/net/i40e/i40e_ethdev_vf.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 5016249..0977095 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1193,7 +1193,6 @@ static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
int i, err, bufsz;
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
- struct ether_addr *p_mac_addr;
uint16_t interval =
i40e_calc_itr_interval(I40E_QUEUE_ITR_INTERVAL_MAX);
@@ -1270,13 +1269,10 @@ static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
vf->vsi.adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
/* Store the MAC address configured by host, or generate random one */
- p_mac_addr = (struct ether_addr *)(vf->vsi_res->default_mac_addr);
- if (is_valid_assigned_ether_addr(p_mac_addr)) { /* Configured by host */
- ether_addr_copy(p_mac_addr, (struct ether_addr *)hw->mac.addr);
+ if (is_valid_assigned_ether_addr((struct ether_addr *)hw->mac.addr))
vf->flags |= I40E_FLAG_VF_MAC_BY_PF;
- } else {
+ else
eth_random_addr(hw->mac.addr); /* Generate a random one */
- }
/* If the PF host is not DPDK, set the interval of ITR0 to max*/
if (vf->version_major != I40E_DPDK_VERSION_MAJOR) {
--
1.9.3
^ permalink raw reply related
* [PATCH v8 00/25] Support VFD on i40e
From: Wenzhuo Lu @ 2017-01-10 7:15 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu
In-Reply-To: <1480637533-37425-1-git-send-email-wenzhuo.lu@intel.com>
1, VF Daemon (VFD)
VFD is an idea to control all the VFs from PF.
As we need to support the scenario kernel PF + DPDK VF,
DPDK follows the interface between kernel PF + kernel
VF.
We don't want to introduce too many new messages
between PF and VF.
So this patch set adds some new APIs to control VFs
directly from PF.
The new APIs include,
1) set VF MAC anti-spoofing
2) set VF VLAN anti-spoofing
3) set TX loopback
4) set VF unicast promiscuous mode
5) set VF multicast promiscuous mode
6) set VF MTU
7) get/reset VF stats
8) set VF MAC address
9) set VF VLAN stripping
10) VF VLAN insertion
12) set VF broadcast mode
12) set VF VLAN tag
13) set VF VLAN filter
VFD also includes VF to PF mailbox message management
by APP.
When PF receives mailbox messages from VF, PF should
call the callback provided by APP to know if they're
permitted to be processed.
2, Implement VF MAC address setting on VF.
v8:
- remove unnecessary VF check.
- add more debug logs.
- split VMDq related code to a separate patch set.
- some minor change.
v7:
- fix 32 bit compile error in patch 23.
- add new patches to configure VMDq.
v6:
- remove the support of DPDK PF + kernel VF. Will create a new patch set for it.
- reword the tittles of some patches.
- add sanity check for vsi, and other minor change.
v5:
- fix testpmd build error(s)
- fix i40e vf_rx_vlan
- remove redundant memset on dev_info
- add functions to .map file sorted
v4:
- rebase on latest next-net
- move patch 10/29 testpmd part to patch 18/29
v3:
- fix issue that VF does not work for i40e
- remove patch for VDMq receive mode init
- move get/reset VF stats API into rte_pmd_i40
v2:
- fix the compile issues.
- fix the checkpatch warning and typo.
- update the commit log of some patches.
- fix the invalid port ID issue of testpmd.
Bernard Iremonger (7):
net/i40e: set VF VLAN insertion from PF
net/i40e: set VF broadcast mode from PF
net/i40e: set VF VLAN tag from PF
net/i40e: set VF VLAN filter from PF
app/testpmd: add command to test VF broadcast mode on i40e
app/testpmd: add command to test VF VLAN tag on i40e
app/testpmd: handle i40e in VF VLAN filter command
Chen Jing D(Mark) (2):
net/i40e: set VF VLAN strip from PF
net/i40e: enhance in sanity check of MAC
Ferruh Yigit (3):
net/i40e: set VF MAC from PF support
net/i40e: set VF MAC from VF support
net/i40e: fix VF MAC address assignment
Qi Zhang (3):
net/i40e: enable VF MTU change
net/i40e: fix VF reset flow
net/i40e: set/clear VF stats from PF
Wenzhuo Lu (10):
net/i40e: support link status notification
net/i40e: add callback to user on VF to PF mbox msg
net/i40e: set VF MAC anti-spoofing from PF
net/i40e: set VF VLAN anti-spoofing from PF
net/i40e: set Tx loopback from PF
net/i40e: set VF unicast promisc mode from PF
net/i40e: set VF multicast promisc mode from PF
app/testpmd: use VFD APIs on i40e
app/testpmd: use unicast promiscuous mode on i40e
app/testpmd: use multicast promiscuous mode on i40e
app/test-pmd/Makefile | 3 +
app/test-pmd/cmdline.c | 587 ++++++++++++++++--
app/test-pmd/config.c | 13 -
app/test-pmd/testpmd.h | 2 -
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 32 +
drivers/net/i40e/Makefile | 4 +-
drivers/net/i40e/i40e_ethdev.c | 921 +++++++++++++++++++++++++++-
drivers/net/i40e/i40e_ethdev.h | 5 +-
drivers/net/i40e/i40e_ethdev_vf.c | 82 ++-
drivers/net/i40e/i40e_pf.c | 244 ++++++--
drivers/net/i40e/i40e_pf.h | 9 +-
drivers/net/i40e/rte_pmd_i40e.h | 332 ++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 20 +
13 files changed, 2139 insertions(+), 115 deletions(-)
create mode 100644 drivers/net/i40e/rte_pmd_i40e.h
--
1.9.3
^ permalink raw reply
* [PATCH v8 01/25] net/i40e: support link status notification
From: Wenzhuo Lu @ 2017-01-10 7:15 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
Add an API to expose the ability, that PF can notify VF
when link status changes, to APP.
So if PF APP doesn't want to enable interruption but check
link status by itself, PF APP can let VF know link status
changed.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/i40e/Makefile | 4 ++-
drivers/net/i40e/i40e_ethdev.c | 23 ++++++++++++
drivers/net/i40e/i40e_pf.c | 4 +--
drivers/net/i40e/i40e_pf.h | 4 ++-
drivers/net/i40e/rte_pmd_i40e.h | 58 +++++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++++
6 files changed, 96 insertions(+), 4 deletions(-)
create mode 100644 drivers/net/i40e/rte_pmd_i40e.h
diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
index 66997b6..4e54e92 100644
--- a/drivers/net/i40e/Makefile
+++ b/drivers/net/i40e/Makefile
@@ -1,6 +1,6 @@
# BSD LICENSE
#
-# Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+# Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -111,6 +111,8 @@ ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_1,$(CFLAGS)),)
CFLAGS_i40e_rxtx_vec_sse.o += -msse4.1
endif
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_I40E_PMD)-include := rte_pmd_i40e.h
# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += lib/librte_eal lib/librte_ether
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f42f4ba..a13d96b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -62,6 +62,7 @@
#include "i40e_rxtx.h"
#include "i40e_pf.h"
#include "i40e_regs.h"
+#include "rte_pmd_i40e.h"
#define ETH_I40E_FLOATING_VEB_ARG "enable_floating_veb"
#define ETH_I40E_FLOATING_VEB_LIST_ARG "floating_veb_list"
@@ -9695,3 +9696,25 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
return ret;
}
+
+int
+rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf)
+{
+ struct rte_eth_dev *dev;
+ struct i40e_pf *pf;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+ if (vf >= pf->vf_num || !pf->vfs) {
+ PMD_DRV_LOG(ERR, "Invalid argument.");
+ return -EINVAL;
+ }
+
+ i40e_notify_vf_link_status(dev, &pf->vfs[vf]);
+
+ return 0;
+}
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index ddfc140..f606c2a 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -897,7 +897,7 @@
return ret;
}
-static void
+void
i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf)
{
struct i40e_virtchnl_pf_event event;
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index cddc45c..47a9c34 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -123,5 +123,7 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
uint8_t *msg, uint16_t msglen);
int i40e_pf_host_init(struct rte_eth_dev *dev);
int i40e_pf_host_uninit(struct rte_eth_dev *dev);
+void i40e_notify_vf_link_status(struct rte_eth_dev *dev,
+ struct i40e_pf_vf *vf);
#endif /* _I40E_PF_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
new file mode 100644
index 0000000..8391347
--- /dev/null
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -0,0 +1,58 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) 2017 Intel Corporation. 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.
+ */
+
+/**
+ * @file rte_pmd_i40e.h
+ * i40e PMD specific functions.
+ *
+ **/
+
+#ifndef _PMD_I40E_H_
+#define _PMD_I40E_H_
+
+#include <rte_ethdev.h>
+
+/**
+ * Notify VF when PF link status changes.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param vf
+ * VF id.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if *vf* invalid.
+ */
+int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
+
+#endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index ef35398..3c6a192 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -2,3 +2,10 @@ DPDK_2.0 {
local: *;
};
+
+DPDK_17.02 {
+ global:
+
+ rte_pmd_i40e_ping_vfs;
+
+} DPDK_2.0;
--
1.9.3
^ permalink raw reply related
* [PATCH v8 02/25] net/i40e: add callback to user on VF to PF mbox msg
From: Wenzhuo Lu @ 2017-01-10 7:15 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
The callback asks the user application if it is allowed to
perform the mailbox messages.
If the return value from user is RTE_PMD_I40E_MB_EVENT_PROCEED
then continue. If ACK or NACK, do nothing and send
not_supported to VF.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/i40e/i40e_pf.c | 230 ++++++++++++++++++++++++++++++++++------
drivers/net/i40e/rte_pmd_i40e.h | 21 ++++
2 files changed, 216 insertions(+), 35 deletions(-)
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index f606c2a..5c58424 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -55,6 +55,7 @@
#include "i40e_ethdev.h"
#include "i40e_rxtx.h"
#include "i40e_pf.h"
+#include "rte_pmd_i40e.h"
#define I40E_CFG_CRCSTRIP_DEFAULT 1
@@ -272,14 +273,23 @@
}
static void
-i40e_pf_host_process_cmd_version(struct i40e_pf_vf *vf)
+i40e_pf_host_process_cmd_version(struct i40e_pf_vf *vf, bool b_op)
{
struct i40e_virtchnl_version_info info;
info.major = I40E_DPDK_VERSION_MAJOR;
info.minor = I40E_DPDK_VERSION_MINOR;
- i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_VERSION,
- I40E_SUCCESS, (uint8_t *)&info, sizeof(info));
+
+ if (b_op)
+ i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_VERSION,
+ I40E_SUCCESS,
+ (uint8_t *)&info,
+ sizeof(info));
+ else
+ i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_VERSION,
+ I40E_NOT_SUPPORTED,
+ (uint8_t *)&info,
+ sizeof(info));
}
static int
@@ -292,13 +302,20 @@
}
static int
-i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf)
+i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, bool b_op)
{
struct i40e_virtchnl_vf_resource *vf_res = NULL;
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
uint32_t len = 0;
int ret = I40E_SUCCESS;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(vf,
+ I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
/* only have 1 VSI by default */
len = sizeof(struct i40e_virtchnl_vf_resource) +
I40E_DEFAULT_VF_VSI_NUM *
@@ -423,7 +440,8 @@
static int
i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
struct i40e_vsi *vsi = vf->vsi;
@@ -432,6 +450,13 @@
struct i40e_virtchnl_queue_pair_info *vc_qpi;
int i, ret = I40E_SUCCESS;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(vf,
+ I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (!msg || vc_vqci->num_queue_pairs > vsi->nb_qps ||
vc_vqci->num_queue_pairs > I40E_MAX_VSI_QP ||
msglen < I40E_VIRTCHNL_CONFIG_VSI_QUEUES_SIZE(vc_vqci,
@@ -482,7 +507,8 @@
static int
i40e_pf_host_process_cmd_config_vsi_queues_ext(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
struct i40e_vsi *vsi = vf->vsi;
@@ -491,6 +517,14 @@
struct i40e_virtchnl_queue_pair_ext_info *vc_qpei;
int i, ret = I40E_SUCCESS;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (!msg || vc_vqcei->num_queue_pairs > vsi->nb_qps ||
vc_vqcei->num_queue_pairs > I40E_MAX_VSI_QP ||
msglen < I40E_VIRTCHNL_CONFIG_VSI_QUEUES_SIZE(vc_vqcei,
@@ -539,12 +573,21 @@
static int
i40e_pf_host_process_cmd_config_irq_map(struct i40e_pf_vf *vf,
- uint8_t *msg, uint16_t msglen)
+ uint8_t *msg, uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_irq_map_info *irqmap =
(struct i40e_virtchnl_irq_map_info *)msg;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen < sizeof(struct i40e_virtchnl_irq_map_info)) {
PMD_DRV_LOG(ERR, "buffer too short");
ret = I40E_ERR_PARAM;
@@ -646,12 +689,21 @@
static int
i40e_pf_host_process_cmd_disable_queues(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_queue_select *q_sel =
(struct i40e_virtchnl_queue_select *)msg;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_DISABLE_QUEUES,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen != sizeof(*q_sel)) {
ret = I40E_ERR_PARAM;
goto send_msg;
@@ -669,7 +721,8 @@
static int
i40e_pf_host_process_cmd_add_ether_address(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_ether_addr_list *addr_list =
@@ -678,6 +731,14 @@
int i;
struct ether_addr *mac;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
memset(&filter, 0 , sizeof(struct i40e_mac_filter_info));
if (msg == NULL || msglen <= sizeof(*addr_list)) {
@@ -707,7 +768,8 @@
static int
i40e_pf_host_process_cmd_del_ether_address(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_ether_addr_list *addr_list =
@@ -715,6 +777,14 @@
int i;
struct ether_addr *mac;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen <= sizeof(*addr_list)) {
PMD_DRV_LOG(ERR, "delete_ether_address argument too short");
ret = I40E_ERR_PARAM;
@@ -739,7 +809,8 @@
static int
i40e_pf_host_process_cmd_add_vlan(struct i40e_pf_vf *vf,
- uint8_t *msg, uint16_t msglen)
+ uint8_t *msg, uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_vlan_filter_list *vlan_filter_list =
@@ -747,6 +818,14 @@
int i;
uint16_t *vid;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_ADD_VLAN,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen <= sizeof(*vlan_filter_list)) {
PMD_DRV_LOG(ERR, "add_vlan argument too short");
ret = I40E_ERR_PARAM;
@@ -771,7 +850,8 @@
static int
i40e_pf_host_process_cmd_del_vlan(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_vlan_filter_list *vlan_filter_list =
@@ -779,6 +859,14 @@
int i;
uint16_t *vid;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_DEL_VLAN,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen <= sizeof(*vlan_filter_list)) {
PMD_DRV_LOG(ERR, "delete_vlan argument too short");
ret = I40E_ERR_PARAM;
@@ -803,7 +891,8 @@
i40e_pf_host_process_cmd_config_promisc_mode(
struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_promisc_info *promisc =
@@ -811,6 +900,14 @@
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
bool unicast = FALSE, multicast = FALSE;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen != sizeof(*promisc)) {
ret = I40E_ERR_PARAM;
goto send_msg;
@@ -836,13 +933,20 @@
}
static int
-i40e_pf_host_process_cmd_get_stats(struct i40e_pf_vf *vf)
+i40e_pf_host_process_cmd_get_stats(struct i40e_pf_vf *vf, bool b_op)
{
i40e_update_vsi_stats(vf->vsi);
- i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_STATS,
- I40E_SUCCESS, (uint8_t *)&vf->vsi->eth_stats,
- sizeof(vf->vsi->eth_stats));
+ if (b_op)
+ i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_STATS,
+ I40E_SUCCESS,
+ (uint8_t *)&vf->vsi->eth_stats,
+ sizeof(vf->vsi->eth_stats));
+ else
+ i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_STATS,
+ I40E_NOT_SUPPORTED,
+ (uint8_t *)&vf->vsi->eth_stats,
+ sizeof(vf->vsi->eth_stats));
return I40E_SUCCESS;
}
@@ -851,12 +955,21 @@
i40e_pf_host_process_cmd_cfg_vlan_offload(
struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_vlan_offload_info *offload =
(struct i40e_virtchnl_vlan_offload_info *)msg;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen != sizeof(*offload)) {
ret = I40E_ERR_PARAM;
goto send_msg;
@@ -877,12 +990,21 @@
static int
i40e_pf_host_process_cmd_cfg_pvid(struct i40e_pf_vf *vf,
uint8_t *msg,
- uint16_t msglen)
+ uint16_t msglen,
+ bool b_op)
{
int ret = I40E_SUCCESS;
struct i40e_virtchnl_pvid_info *tpid_info =
(struct i40e_virtchnl_pvid_info *)msg;
+ if (!b_op) {
+ i40e_pf_host_send_msg_to_vf(
+ vf,
+ I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ return ret;
+ }
+
if (msg == NULL || msglen != sizeof(*tpid_info)) {
ret = I40E_ERR_PARAM;
goto send_msg;
@@ -923,6 +1045,8 @@
struct i40e_pf_vf *vf;
/* AdminQ will pass absolute VF id, transfer to internal vf id */
uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;
+ struct rte_pmd_i40e_mb_event_param cb_param;
+ bool b_op = TRUE;
if (vf_id > pf->vf_num - 1 || !pf->vfs) {
PMD_DRV_LOG(ERR, "invalid argument");
@@ -937,10 +1061,35 @@
return;
}
+ /**
+ * initialise structure to send to user application
+ * will return response from user in retval field
+ */
+ cb_param.retval = RTE_PMD_I40E_MB_EVENT_PROCEED;
+ cb_param.vfid = vf_id;
+ cb_param.msg_type = opcode;
+ cb_param.msg = (void *)msg;
+ cb_param.msglen = msglen;
+
+ /**
+ * Ask user application if we're allowed to perform those functions.
+ * If we get cb_param.retval == RTE_PMD_I40E_MB_EVENT_PROCEED,
+ * then business as usual.
+ * If RTE_PMD_I40E_MB_EVENT_NOOP_ACK or RTE_PMD_I40E_MB_EVENT_NOOP_NACK,
+ * do nothing and send not_supported to VF. As PF must send a response
+ * to VF and ACK/NACK is not defined.
+ */
+ _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_VF_MBOX, &cb_param);
+ if (cb_param.retval != RTE_PMD_I40E_MB_EVENT_PROCEED) {
+ PMD_DRV_LOG(WARNING, "VF to PF message(%d) is not permitted!",
+ opcode);
+ b_op = FALSE;
+ }
+
switch (opcode) {
case I40E_VIRTCHNL_OP_VERSION :
PMD_DRV_LOG(INFO, "OP_VERSION received");
- i40e_pf_host_process_cmd_version(vf);
+ i40e_pf_host_process_cmd_version(vf, b_op);
break;
case I40E_VIRTCHNL_OP_RESET_VF :
PMD_DRV_LOG(INFO, "OP_RESET_VF received");
@@ -948,61 +1097,72 @@
break;
case I40E_VIRTCHNL_OP_GET_VF_RESOURCES:
PMD_DRV_LOG(INFO, "OP_GET_VF_RESOURCES received");
- i40e_pf_host_process_cmd_get_vf_resource(vf);
+ i40e_pf_host_process_cmd_get_vf_resource(vf, b_op);
break;
case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES:
PMD_DRV_LOG(INFO, "OP_CONFIG_VSI_QUEUES received");
- i40e_pf_host_process_cmd_config_vsi_queues(vf, msg, msglen);
+ i40e_pf_host_process_cmd_config_vsi_queues(vf, msg,
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT:
PMD_DRV_LOG(INFO, "OP_CONFIG_VSI_QUEUES_EXT received");
i40e_pf_host_process_cmd_config_vsi_queues_ext(vf, msg,
- msglen);
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_CONFIG_IRQ_MAP:
PMD_DRV_LOG(INFO, "OP_CONFIG_IRQ_MAP received");
- i40e_pf_host_process_cmd_config_irq_map(vf, msg, msglen);
+ i40e_pf_host_process_cmd_config_irq_map(vf, msg, msglen, b_op);
break;
case I40E_VIRTCHNL_OP_ENABLE_QUEUES:
PMD_DRV_LOG(INFO, "OP_ENABLE_QUEUES received");
- i40e_pf_host_process_cmd_enable_queues(vf, msg, msglen);
- i40e_notify_vf_link_status(dev, vf);
+ if (b_op) {
+ i40e_pf_host_process_cmd_enable_queues(vf, msg, msglen);
+ i40e_notify_vf_link_status(dev, vf);
+ } else {
+ i40e_pf_host_send_msg_to_vf(
+ vf, I40E_VIRTCHNL_OP_ENABLE_QUEUES,
+ I40E_NOT_SUPPORTED, NULL, 0);
+ }
break;
case I40E_VIRTCHNL_OP_DISABLE_QUEUES:
PMD_DRV_LOG(INFO, "OP_DISABLE_QUEUE received");
- i40e_pf_host_process_cmd_disable_queues(vf, msg, msglen);
+ i40e_pf_host_process_cmd_disable_queues(vf, msg, msglen, b_op);
break;
case I40E_VIRTCHNL_OP_ADD_ETHER_ADDRESS:
PMD_DRV_LOG(INFO, "OP_ADD_ETHER_ADDRESS received");
- i40e_pf_host_process_cmd_add_ether_address(vf, msg, msglen);
+ i40e_pf_host_process_cmd_add_ether_address(vf, msg,
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_DEL_ETHER_ADDRESS:
PMD_DRV_LOG(INFO, "OP_DEL_ETHER_ADDRESS received");
- i40e_pf_host_process_cmd_del_ether_address(vf, msg, msglen);
+ i40e_pf_host_process_cmd_del_ether_address(vf, msg,
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_ADD_VLAN:
PMD_DRV_LOG(INFO, "OP_ADD_VLAN received");
- i40e_pf_host_process_cmd_add_vlan(vf, msg, msglen);
+ i40e_pf_host_process_cmd_add_vlan(vf, msg, msglen, b_op);
break;
case I40E_VIRTCHNL_OP_DEL_VLAN:
PMD_DRV_LOG(INFO, "OP_DEL_VLAN received");
- i40e_pf_host_process_cmd_del_vlan(vf, msg, msglen);
+ i40e_pf_host_process_cmd_del_vlan(vf, msg, msglen, b_op);
break;
case I40E_VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE:
PMD_DRV_LOG(INFO, "OP_CONFIG_PROMISCUOUS_MODE received");
- i40e_pf_host_process_cmd_config_promisc_mode(vf, msg, msglen);
+ i40e_pf_host_process_cmd_config_promisc_mode(vf, msg,
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_GET_STATS:
PMD_DRV_LOG(INFO, "OP_GET_STATS received");
- i40e_pf_host_process_cmd_get_stats(vf);
+ i40e_pf_host_process_cmd_get_stats(vf, b_op);
break;
case I40E_VIRTCHNL_OP_CFG_VLAN_OFFLOAD:
PMD_DRV_LOG(INFO, "OP_CFG_VLAN_OFFLOAD received");
- i40e_pf_host_process_cmd_cfg_vlan_offload(vf, msg, msglen);
+ i40e_pf_host_process_cmd_cfg_vlan_offload(vf, msg,
+ msglen, b_op);
break;
case I40E_VIRTCHNL_OP_CFG_VLAN_PVID:
PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
- i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen);
+ i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op);
break;
/* Don't add command supported below, which will
* return an error code.
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 8391347..8fed94c 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -42,6 +42,27 @@
#include <rte_ethdev.h>
/**
+ * Response sent back to i40e driver from user app after callback
+ */
+enum rte_pmd_i40e_mb_event_rsp {
+ RTE_PMD_I40E_MB_EVENT_NOOP_ACK, /**< skip mbox request and ACK */
+ RTE_PMD_I40E_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
+ RTE_PMD_I40E_MB_EVENT_PROCEED, /**< proceed with mbox request */
+ RTE_PMD_I40E_MB_EVENT_MAX /**< max value of this enum */
+};
+
+/**
+ * Data sent to the user application when the callback is executed.
+ */
+struct rte_pmd_i40e_mb_event_param {
+ uint16_t vfid; /**< Virtual Function number */
+ uint16_t msg_type; /**< VF to PF message type, see i40e_virtchnl_ops */
+ uint16_t retval; /**< return value */
+ void *msg; /**< pointer to message */
+ uint16_t msglen; /**< length of the message */
+};
+
+/**
* Notify VF when PF link status changes.
*
* @param port
--
1.9.3
^ permalink raw reply related
* [PATCH v8 03/25] net/i40e: set VF MAC anti-spoofing from PF
From: Wenzhuo Lu @ 2017-01-10 7:15 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
Support enabling/disabling VF MAC anti-spoofing from
PF.
User can call the API on PF to enable/disable a specific
VF's MAC anti-spoofing.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 62 +++++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e.h | 19 ++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 1 +
3 files changed, 82 insertions(+)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index a13d96b..eba5168 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -9718,3 +9718,65 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
return 0;
}
+
+int
+rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf_id, uint8_t on)
+{
+ struct rte_eth_dev *dev;
+ struct i40e_pf *pf;
+ struct i40e_vsi *vsi;
+ struct i40e_hw *hw;
+ struct i40e_vsi_context ctxt;
+ int ret;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+ if (vf_id >= pf->vf_num || !pf->vfs) {
+ PMD_DRV_LOG(ERR, "Invalid argument.");
+ return -EINVAL;
+ }
+
+ vsi = pf->vfs[vf_id].vsi;
+ if (!vsi) {
+ PMD_DRV_LOG(ERR, "Invalid VSI.");
+ return -EINVAL;
+ }
+
+ /* Check if it has been already on or off */
+ if (vsi->info.valid_sections &
+ rte_cpu_to_le_16(I40E_AQ_VSI_PROP_SECURITY_VALID)) {
+ if (on) {
+ if ((vsi->info.sec_flags &
+ I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK) ==
+ I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK)
+ return 0; /* already on */
+ } else {
+ if ((vsi->info.sec_flags &
+ I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK) == 0)
+ return 0; /* already off */
+ }
+ }
+
+ vsi->info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID);
+ if (on)
+ vsi->info.sec_flags |= I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK;
+ else
+ vsi->info.sec_flags &= ~I40E_AQ_VSI_SEC_FLAG_ENABLE_MAC_CHK;
+
+ memset(&ctxt, 0, sizeof(ctxt));
+ (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info));
+ ctxt.seid = vsi->seid;
+
+ hw = I40E_VSI_TO_HW(vsi);
+ ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
+ if (ret != I40E_SUCCESS) {
+ ret = -ENOTSUP;
+ PMD_DRV_LOG(ERR, "Failed to update VSI params");
+ }
+
+ return ret;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 8fed94c..95519aa 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -76,4 +76,23 @@ struct rte_pmd_i40e_mb_event_param {
*/
int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
+/**
+ * Enable/Disable VF MAC anti spoofing.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param vf
+ * VF on which to set MAC anti spoofing.
+ * @param on
+ * 1 - Enable VFs MAC anti spoofing.
+ * 0 - Disable VFs MAC anti spoofing.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
+ uint16_t vf_id,
+ uint8_t on);
+
#endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 3c6a192..0581209 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -7,5 +7,6 @@ DPDK_17.02 {
global:
rte_pmd_i40e_ping_vfs;
+ rte_pmd_i40e_set_vf_mac_anti_spoof;
} DPDK_2.0;
--
1.9.3
^ permalink raw reply related
* [PATCH v8 04/25] net/i40e: set VF VLAN anti-spoofing from PF
From: Wenzhuo Lu @ 2017-01-10 7:15 UTC (permalink / raw)
To: dev; +Cc: Wenzhuo Lu
In-Reply-To: <1484032580-60134-1-git-send-email-wenzhuo.lu@intel.com>
Support enabling/disabling VF VLAN anti-spoofing from
PF.
User can call the API on PF to enable/disable a specific
VF's VLAN anti-spoofing.
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
drivers/net/i40e/i40e_ethdev.c | 137 ++++++++++++++++++++++++++++--
drivers/net/i40e/i40e_ethdev.h | 1 +
drivers/net/i40e/rte_pmd_i40e.h | 19 +++++
drivers/net/i40e/rte_pmd_i40e_version.map | 1 +
4 files changed, 153 insertions(+), 5 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index eba5168..3d126a1 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -4418,6 +4418,7 @@ struct i40e_vsi *
vsi->max_macaddrs = I40E_NUM_MACADDR_MAX;
vsi->parent_vsi = uplink_vsi ? uplink_vsi : pf->main_vsi;
vsi->user_param = user_param;
+ vsi->vlan_anti_spoof_on = 0;
/* Allocate queues */
switch (vsi->type) {
case I40E_VSI_MAIN :
@@ -5757,14 +5758,11 @@ struct i40e_vsi *
}
static void
-i40e_set_vlan_filter(struct i40e_vsi *vsi,
- uint16_t vlan_id, bool on)
+i40e_store_vlan_filter(struct i40e_vsi *vsi,
+ uint16_t vlan_id, bool on)
{
uint32_t vid_idx, vid_bit;
- if (vlan_id > ETH_VLAN_ID_MAX)
- return;
-
vid_idx = I40E_VFTA_IDX(vlan_id);
vid_bit = I40E_VFTA_BIT(vlan_id);
@@ -5774,6 +5772,38 @@ struct i40e_vsi *
vsi->vfta[vid_idx] &= ~vid_bit;
}
+static void
+i40e_set_vlan_filter(struct i40e_vsi *vsi,
+ uint16_t vlan_id, bool on)
+{
+ struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+ struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};
+ int ret;
+
+ if (vlan_id > ETH_VLAN_ID_MAX)
+ return;
+
+ i40e_store_vlan_filter(vsi, vlan_id, on);
+
+ if (!vsi->vlan_anti_spoof_on || !vlan_id)
+ return;
+
+ vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
+
+ if (on) {
+ ret = i40e_aq_add_vlan(hw, vsi->seid,
+ &vlan_data, 1, NULL);
+ if (ret != I40E_SUCCESS)
+ PMD_DRV_LOG(ERR, "Failed to add vlan filter");
+ } else {
+ ret = i40e_aq_remove_vlan(hw, vsi->seid,
+ &vlan_data, 1, NULL);
+ if (ret != I40E_SUCCESS)
+ PMD_DRV_LOG(ERR,
+ "Failed to remove vlan filter");
+ }
+}
+
/**
* Find all vlan options for specific mac addr,
* return with actual vlan found.
@@ -9780,3 +9810,100 @@ static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
return ret;
}
+
+static int
+i40e_add_rm_all_vlan_filter(struct i40e_vsi *vsi, uint8_t add)
+{
+ uint32_t j, k;
+ uint16_t vlan_id;
+ struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
+ struct i40e_aqc_add_remove_vlan_element_data vlan_data = {0};
+ int ret;
+
+ for (j = 0; j < I40E_VFTA_SIZE; j++) {
+ if (!vsi->vfta[j])
+ continue;
+
+ for (k = 0; k < I40E_UINT32_BIT_SIZE; k++) {
+ if (!(vsi->vfta[j] & (1 << k)))
+ continue;
+
+ vlan_id = j * I40E_UINT32_BIT_SIZE + k;
+ if (!vlan_id)
+ continue;
+
+ vlan_data.vlan_tag = rte_cpu_to_le_16(vlan_id);
+ if (add)
+ ret = i40e_aq_add_vlan(hw, vsi->seid,
+ &vlan_data, 1, NULL);
+ else
+ ret = i40e_aq_remove_vlan(hw, vsi->seid,
+ &vlan_data, 1, NULL);
+ if (ret != I40E_SUCCESS) {
+ PMD_DRV_LOG(ERR,
+ "Failed to add/rm vlan filter");
+ return ret;
+ }
+ }
+ }
+
+ return I40E_SUCCESS;
+}
+
+int
+rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf_id, uint8_t on)
+{
+ struct rte_eth_dev *dev;
+ struct i40e_pf *pf;
+ struct i40e_vsi *vsi;
+ struct i40e_hw *hw;
+ struct i40e_vsi_context ctxt;
+ int ret;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+
+ pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+ if (vf_id >= pf->vf_num || !pf->vfs) {
+ PMD_DRV_LOG(ERR, "Invalid argument.");
+ return -EINVAL;
+ }
+
+ vsi = pf->vfs[vf_id].vsi;
+ if (!vsi) {
+ PMD_DRV_LOG(ERR, "Invalid VSI.");
+ return -EINVAL;
+ }
+
+ /* Check if it has been already on or off */
+ if (vsi->vlan_anti_spoof_on == on)
+ return 0; /* already on or off */
+
+ vsi->vlan_anti_spoof_on = on;
+ ret = i40e_add_rm_all_vlan_filter(vsi, on);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Failed to remove VLAN filters.");
+ return -ENOTSUP;
+ }
+
+ vsi->info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SECURITY_VALID);
+ if (on)
+ vsi->info.sec_flags |= I40E_AQ_VSI_SEC_FLAG_ENABLE_VLAN_CHK;
+ else
+ vsi->info.sec_flags &= ~I40E_AQ_VSI_SEC_FLAG_ENABLE_VLAN_CHK;
+
+ memset(&ctxt, 0, sizeof(ctxt));
+ (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info));
+ ctxt.seid = vsi->seid;
+
+ hw = I40E_VSI_TO_HW(vsi);
+ ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL);
+ if (ret != I40E_SUCCESS) {
+ ret = -ENOTSUP;
+ PMD_DRV_LOG(ERR, "Failed to update VSI params");
+ }
+
+ return ret;
+}
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 298cef4..0db140b 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -300,6 +300,7 @@ struct i40e_vsi {
uint16_t msix_intr; /* The MSIX interrupt binds to VSI */
uint16_t nb_msix; /* The max number of msix vector */
uint8_t enabled_tc; /* The traffic class enabled */
+ uint8_t vlan_anti_spoof_on; /* The VLAN anti-spoofing enabled */
struct i40e_bw_info bw_info; /* VSI bandwidth information */
};
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 95519aa..9546c84 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -95,4 +95,23 @@ int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
uint16_t vf_id,
uint8_t on);
+/**
+ * Enable/Disable VF VLAN anti spoofing.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param vf
+ * VF on which to set VLAN anti spoofing.
+ * @param on
+ * 1 - Enable VFs VLAN anti spoofing.
+ * 0 - Disable VFs VLAN anti spoofing.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
+ uint16_t vf_id,
+ uint8_t on);
+
#endif /* _PMD_I40E_H_ */
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 0581209..028f0ef 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -8,5 +8,6 @@ DPDK_17.02 {
rte_pmd_i40e_ping_vfs;
rte_pmd_i40e_set_vf_mac_anti_spoof;
+ rte_pmd_i40e_set_vf_vlan_anti_spoof;
} DPDK_2.0;
--
1.9.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox