[dpdk-dev] [DPDK] net/ice: support show RSS hash configuration
From: Zhu Tao Implement interface 'ice_rss_hash_conf_get' to support show RSS hash configuration. Note: Not support the same time set RSS with RTE and classify API. Signed-off-by: Zhu Tao --- drivers/net/ice/ice_ethdev.c | 15 +-- drivers/net/ice/ice_ethdev.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index d51f3faba..ff8106317 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2923,6 +2923,16 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) struct ice_vsi *vsi = pf->main_vsi; int ret; +#define ICE_RSS_HF_ALL ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_NONFRAG_IPV6_UDP | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV4_SCTP | \ + ETH_RSS_NONFRAG_IPV6_SCTP) + /* Configure RSS for IPv4 with src/dst addr as input set */ if (rss_hf & ETH_RSS_IPV4) { ret = ice_add_rss_cfg_wrap(pf, vsi->idx, ICE_FLOW_HASH_IPV4, @@ -3216,6 +3226,8 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) PMD_DRV_LOG(ERR, "%s GTPU_EH_IPV6_SCTP rss flow fail %d", __func__, ret); } + + pf->rss_hf = rss_hf & ICE_RSS_HF_ALL; } static int ice_init_rss(struct ice_pf *pf) @@ -4439,8 +4451,7 @@ ice_rss_hash_conf_get(struct rte_eth_dev *dev, ice_get_rss_key(vsi, rss_conf->rss_key, &rss_conf->rss_key_len); - /* TODO: default set to 0 as hf config is not supported now */ - rss_conf->rss_hf = 0; + rss_conf->rss_hf = pf->rss_hf; return 0; } diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 05218af05..452fd9050 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -457,6 +457,7 @@ struct ice_pf { uint64_t old_rx_bytes; uint64_t old_tx_bytes; uint64_t supported_rxdid; /* bitmap for supported RXDID */ + uint64_t rss_hf; }; #define ICE_MAX_QUEUE_NUM 2048 -- 2.18.4
[dpdk-dev] [PATCH v2] net/ice: support show RSS hash configuration
From: Zhu Tao Implement interface 'ice_rss_hash_conf_get' to support show RSS hash configuration. Note: Not support the same time setting RSS with RTE and classify API. Signed-off-by: Zhu Tao --- drivers/net/ice/ice_ethdev.c | 15 +-- drivers/net/ice/ice_ethdev.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) v2 changes: Committed log. diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index d51f3faba..ff8106317 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2923,6 +2923,16 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) struct ice_vsi *vsi = pf->main_vsi; int ret; +#define ICE_RSS_HF_ALL ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_NONFRAG_IPV6_UDP | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV4_SCTP | \ + ETH_RSS_NONFRAG_IPV6_SCTP) + /* Configure RSS for IPv4 with src/dst addr as input set */ if (rss_hf & ETH_RSS_IPV4) { ret = ice_add_rss_cfg_wrap(pf, vsi->idx, ICE_FLOW_HASH_IPV4, @@ -3216,6 +3226,8 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) PMD_DRV_LOG(ERR, "%s GTPU_EH_IPV6_SCTP rss flow fail %d", __func__, ret); } + + pf->rss_hf = rss_hf & ICE_RSS_HF_ALL; } static int ice_init_rss(struct ice_pf *pf) @@ -4439,8 +4451,7 @@ ice_rss_hash_conf_get(struct rte_eth_dev *dev, ice_get_rss_key(vsi, rss_conf->rss_key, &rss_conf->rss_key_len); - /* TODO: default set to 0 as hf config is not supported now */ - rss_conf->rss_hf = 0; + rss_conf->rss_hf = pf->rss_hf; return 0; } diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 05218af05..452fd9050 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -457,6 +457,7 @@ struct ice_pf { uint64_t old_rx_bytes; uint64_t old_tx_bytes; uint64_t supported_rxdid; /* bitmap for supported RXDID */ + uint64_t rss_hf; }; #define ICE_MAX_QUEUE_NUM 2048 -- 2.18.4
[dpdk-dev] [PATCH v3] net/ice: support show RSS hash configuration
From: Zhu Tao Implement interface 'ice_rss_hash_conf_get' to support show RSS hash configuration. Note: Not support the same time setting RSS with RTE and classify API. Only return rss_hf from latest dev_configure or dev_rss_hash_update. All configures from rte_flow are ignored. Signed-off-by: Zhu Tao Acked-by: Qi Zhang --- drivers/net/ice/ice_ethdev.c | 15 +-- drivers/net/ice/ice_ethdev.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) v2, v3 changes: Committed log. diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index d51f3faba..ff8106317 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2923,6 +2923,16 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) struct ice_vsi *vsi = pf->main_vsi; int ret; +#define ICE_RSS_HF_ALL ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_NONFRAG_IPV6_UDP | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV4_SCTP | \ + ETH_RSS_NONFRAG_IPV6_SCTP) + /* Configure RSS for IPv4 with src/dst addr as input set */ if (rss_hf & ETH_RSS_IPV4) { ret = ice_add_rss_cfg_wrap(pf, vsi->idx, ICE_FLOW_HASH_IPV4, @@ -3216,6 +3226,8 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) PMD_DRV_LOG(ERR, "%s GTPU_EH_IPV6_SCTP rss flow fail %d", __func__, ret); } + + pf->rss_hf = rss_hf & ICE_RSS_HF_ALL; } static int ice_init_rss(struct ice_pf *pf) @@ -4439,8 +4451,7 @@ ice_rss_hash_conf_get(struct rte_eth_dev *dev, ice_get_rss_key(vsi, rss_conf->rss_key, &rss_conf->rss_key_len); - /* TODO: default set to 0 as hf config is not supported now */ - rss_conf->rss_hf = 0; + rss_conf->rss_hf = pf->rss_hf; return 0; } diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 05218af05..452fd9050 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -457,6 +457,7 @@ struct ice_pf { uint64_t old_rx_bytes; uint64_t old_tx_bytes; uint64_t supported_rxdid; /* bitmap for supported RXDID */ + uint64_t rss_hf; }; #define ICE_MAX_QUEUE_NUM 2048 -- 2.18.4
[dpdk-dev] [PATCH] net/ixgbe: fix blocking system events
From: Zhu Tao IXGBE link status task use rte alarm thread in old implementation. Sometime ixgbe link status task takes up to 9 seconds. This will severely affect the rte-alarm-thread-dependent a task in the system, like interrupt or hotplug event. So replace with a independent thread which has the same thread affinity settings as rte interrupt. Fixes: 0408f47b ("net/ixgbe: fix busy polling while fiber link update") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 184 +-- drivers/net/ixgbe/ixgbe_ethdev.h | 32 +++ 2 files changed, 210 insertions(+), 6 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c6fd0f..f0b387d 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -378,6 +379,9 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); static int ixgbe_filter_restore(struct rte_eth_dev *dev); static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev); +static int ixgbe_task_thread_init(struct rte_eth_dev *dev); +static void ixgbe_task_thread_uninit(struct rte_eth_dev *dev); + /* * Define VF Stats MACRO for Non "cleared on read" register @@ -1069,6 +1073,171 @@ struct rte_ixgbe_xstats_name_off { } /* + * Add a task to task queue tail. + */ +int ixgbe_add_task(struct rte_eth_dev *dev, ixgbe_task_cb_fn task_cb) +{ + struct ixgbe_adapter *ad = dev->data->dev_private; + struct ixgbe_task *task; + + if (ad->task_status == IXGBE_TASK_THREAD_RUNNING) { + task = rte_zmalloc("ixgbe", sizeof(struct ixgbe_task), 0); + if (task == NULL) + return -ENOMEM; + + task->arg = dev; + task->task_cb = task_cb; + task->status = IXGBE_TASK_READY; + + pthread_mutex_lock(&ad->task_lock); + TAILQ_INSERT_TAIL(&ad->task_head, task, next); + pthread_cond_signal(&ad->task_cond); + pthread_mutex_unlock(&ad->task_lock); + } else { + return -EPERM; /* Operation not permitted */ + } + + return 0; +} + +/* + * Sync cancel a task with all @task_cb be exit. + */ +int ixgbe_cancel_task(struct rte_eth_dev *dev, ixgbe_task_cb_fn task_cb) +{ + struct ixgbe_adapter *ad = dev->data->dev_private; + struct ixgbe_task *task, *ttask; + int i, executing; +#define DELAY_TIMEOUT_LOG 2000 // 2s +#define DELAY_TIMEOUT_MAX 1 // 10s + + for (i = 0; i < DELAY_TIMEOUT_MAX; i++) { + executing = 0; + if (ad->task_status == IXGBE_TASK_THREAD_RUNNING) { + pthread_mutex_lock(&ad->task_lock); + TAILQ_FOREACH_SAFE(task, &ad->task_head, next, ttask) { + if (task->task_cb == task_cb) { + if (task->status == IXGBE_TASK_RUNNING) { + executing++; + } else { + TAILQ_REMOVE(&ad->task_head, task, next); + rte_free(task); + } + } + } + pthread_mutex_unlock(&ad->task_lock); + + if (executing) { + if (i > DELAY_TIMEOUT_LOG && (i % 1000 == 0)) { + PMD_DRV_LOG(WARNING, + "Cannel task time wait %ds!", i / 1000); + } + + rte_delay_us_sleep(1000); // 1ms + continue; + } + } + break; + } + + if (i == DELAY_TIMEOUT_MAX) + return -EBUSY; + + return 0; +} + +/* + * Task main thread. Loop until state is set to IXGBE_TASK_THREAD_EXIT. + * For each task, set the status to IXGBE_TASK_RUNNING before execution, + * execute and then be dequeue. + */ +static void *ixgbe_task_handler(void *args) +{ + struct ixgbe_adapter *ad = + ((struct rte_eth_dev *)args)->data->dev_private; + struct ixgbe_task *task; + + PMD_INIT_LOG(DEBUG, "ixgbe task thread created"); + while (ad->task_status) { + pthread_mutex_lock(&ad->task_lock); + if (TAILQ_EMPTY(&ad->task_head)) { + pthread_cond_wait(&ad->task_cond, &ad->task_lock); + pthread_mutex_unlock(&ad->task_lock); + continue; + } + + /* pop firt task and run it */ + task
[dpdk-dev] [PATCH v3] net/i40e: add PF MDD event handler
From: Zhu Tao add warning and counter to handle the maliciouse driver detection event. Signed-off-by: Zhu Tao --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 ++ drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 93 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index 38acf5906..539ea5c57 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 0eaa45a76..5f39006a4 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -56,6 +56,10 @@ New Features Also, make sure to start the actual text at the margin. = +* **Updated the Intel i40e driver.** + + Added PF support Malicious Device Drive event catch and notify. + Removed Items - diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5999c964b..a66069b48 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); + PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n"); + } + } + + /* see if one of the VFs needs its hand slapped */ + for (i = 0; i < pf->vf_num && mdd_detected; i++) { + vf = &pf->vfs[i]; + reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i)); + if (reg & I40E_VP_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0x); + vf->num_mdd_events++; + PMD_DRV_LOG(WARNING, "TX driver
[dpdk-dev] [PATCH v4] net/i40e: add PF MDD event handler
From: Zhu Tao add warning and counter to handle the maliciouse driver detection event. update doc/guides/nics/i40e.rst update doc/guides/rel_notes/release_20_02.rst Signed-off-by: Zhu Tao --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 +- drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index c7c34b62f..2bf11e8ca 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..a39f1 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -66,11 +66,13 @@ New Features * Added support for RSS using L3/L4 source/destination only. -* **Updated i40e driver to support L2TPv3 over IP flows.** +* **Updated i40e driver.** Updated the i40e PMD to support L2TPv3 over IP profiles which can be programmed by the dynamic device personalization (DDP) process. + Added PF support Malicious Device Drive event catch and notify. + * **Updated testpmd to support L2TPv3 over IP flows.** Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..95bfed4d9 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); + PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n"); + } + } + + /* see if one of the VFs needs its hand slapped */ + for (i = 0; i < pf->vf_num && mdd_detected; i++) { + vf =
[dpdk-dev] [PATCH v2] net/ixgbe: fix blocking system events
From: Zhu Tao IXGBE link status task use rte alarm thread in old implementation. Sometime ixgbe link status task takes up to 9 seconds. This will severely affect the rte-alarm-thread-dependent a task in the system, like interrupt or hotplug event. So replace with a independent thread which has the same thread affinity settings as rte interrupt. Fixes: 0408f47b ("net/ixgbe: fix busy polling while fiber link update") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 50 +++- drivers/net/ixgbe/ixgbe_ethdev.h | 2 ++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 7ea1962f6..2d692e54c 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -229,7 +229,8 @@ static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev); static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev); static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); -static void ixgbe_dev_setup_link_alarm_handler(void *param); +static void *ixgbe_dev_setup_link_thread_handler(void *param); +static void ixgbe_dev_cannel_link_thread(struct rte_eth_dev *dev); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -1078,6 +1079,7 @@ ixgbe_swfw_lock_reset(struct ixgbe_hw *hw) static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) { + struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1129,6 +1131,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) return 0; } + rte_atomic32_clear(&ad->link_thread_running); rte_eth_copy_pci_info(eth_dev, pci_dev); /* Vendor and Device ID need to be set before init of shared code */ @@ -1567,6 +1570,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) { int diag; uint32_t tc, tcs; + struct ixgbe_adapter *ad = eth_dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct ixgbe_hw *hw = @@ -1607,6 +1611,7 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev) return 0; } + rte_atomic32_clear(&ad->link_thread_running); ixgbevf_parse_devargs(eth_dev->data->dev_private, pci_dev->device.devargs); @@ -2563,7 +2568,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cannel_link_thread(dev); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2844,7 +2849,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev); + ixgbe_dev_cannel_link_thread(dev); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4098,9 +4103,23 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, } static void -ixgbe_dev_setup_link_alarm_handler(void *param) +ixgbe_dev_cannel_link_thread(struct rte_eth_dev *dev) +{ + struct ixgbe_adapter *ad = dev->data->dev_private; + void *retval; + + if (rte_atomic32_read(&ad->link_thread_running)) { + pthread_cancel(ad->link_thread_tid); + pthread_join(ad->link_thread_tid, &retval); + rte_atomic32_clear(&ad->link_thread_running); + } +} + +static void * +ixgbe_dev_setup_link_thread_handler(void *param) { struct rte_eth_dev *dev = (struct rte_eth_dev *)param; + struct ixgbe_adapter *ad = dev->data->dev_private; struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ixgbe_interrupt *intr = IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); @@ -4114,6 +4133,8 @@ ixgbe_dev_setup_link_alarm_handler(void *param) ixgbe_setup_link(hw, speed, true); intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; + rte_atomic32_clear(&ad->link_thread_running); + return NULL; } /* @@ -4153,6 +4174,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, int wait_to_complete, int vf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ixgbe_adapter *ad = dev->data->dev_private; struct rte_eth_link link; ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; struct ixgbe_interrupt *intr = @@ -4198,8 +42
[dpdk-dev] [PATCH v5] net/i40e: add PF MDD event handler
From: Zhu Tao add warning and counter to handle the maliciouse driver detection event. When the hardware determines that a VF has maliciouse driver, this VF will become unworkable, the PF records and gives a warning message. Signed-off-by: Zhu Tao Acked-by: Qiming Yang --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 +- drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 92 insertions(+), 3 deletions(-) v5: - Change commit message v4: - Change commit message - Rebase doc/guides/rel_notes/release_20_02.rst v3: - Change commit message diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index c7c34b62f..2bf11e8ca 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..a39f1 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -66,11 +66,13 @@ New Features * Added support for RSS using L3/L4 source/destination only. -* **Updated i40e driver to support L2TPv3 over IP flows.** +* **Updated i40e driver.** Updated the i40e PMD to support L2TPv3 over IP profiles which can be programmed by the dynamic device personalization (DDP) process. + Added PF support Malicious Device Drive event catch and notify. + * **Updated testpmd to support L2TPv3 over IP flows.** Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..95bfed4d9 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); + PMD_DRV_LOG
[dpdk-dev] [PATCH] net/ice: fix flow fdir/switch memory leak.
From: Tao Zhu 1. Fix ice fdir and hash flow memory leak. 2. Fix the ice definition of LIST_FOR_EACH_ENTRY_SAFE not save tmp which cause list deletion incompletely. Fixes: 5f0978e9622 ("net/ice/base: add OS specific implementation") Fixes: f5cafa961fa ("net/ice: add flow director create and destroy") Fixes: 5ad3db8d4bd ("net/ice: enable advanced RSS") Signed-off-by: Tao Zhu Reviewed-by: Su, Simei Reviewed-by: Cao, Yahui --- drivers/net/ice/base/ice_osdep.h | 17 +++-- drivers/net/ice/ice_fdir_filter.c | 12 +++- drivers/net/ice/ice_hash.c| 12 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) - File drivers/net/ice/base/ice_osdep.h need someone to review. - File drivers/net/ice/ice_fdir_filter.c reviewed by Yahui. - File drivers/net/ice/ice_hash.c reviewed by Simei. diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index 27c1830..4b37406 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -343,6 +343,21 @@ static inline void list_add_tail(struct ice_list_entry *entry, member) :\ 0) +#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member)\ + for ((pos) = (head)->lh_first ?\ +container_of((head)->lh_first, struct type, member) : \ +0,\ +(tmp) = (pos) == 0 ? 0 : ((pos)->member.next.le_next ?\ +container_of((pos)->member.next.le_next, struct type, \ + member) :\ +0); \ +(pos);\ +(pos) = (tmp),\ +(tmp) = (pos) == 0 ? 0 : ((tmp)->member.next.le_next ?\ +container_of((pos)->member.next.le_next, struct type, \ + member) :\ +0)) + #define LIST_REPLACE_INIT(list_head, head) do { \ (head)->lh_first = (list_head)->lh_first; \ INIT_LIST_HEAD(list_head); \ @@ -356,8 +371,6 @@ static inline void list_add_tail(struct ice_list_entry *entry, #define HLIST_DEL(entry) LIST_DEL(entry) #define HLIST_FOR_EACH_ENTRY(pos, head, type, member) \ LIST_FOR_EACH_ENTRY(pos, head, type, member) -#define LIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member) \ - LIST_FOR_EACH_ENTRY(pos, head, type, member) #ifndef ICE_DBG_TRACE #define ICE_DBG_TRACE BIT_ULL(0) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index fa87074..c31a736 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1938,23 +1938,25 @@ ret = ice_fdir_parse_pattern(ad, pattern, error, filter); if (ret) - return ret; + goto error; input_set = filter->input_set; if (!input_set || input_set & ~item->input_set_mask) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC, pattern, "Invalid input set"); - return -rte_errno; + ret = -rte_errno; + goto error; } ret = ice_fdir_parse_action(ad, actions, error, filter); if (ret) - return ret; + goto error; *meta = filter; - - return 0; +error: + rte_free(item); + return ret; } static struct ice_flow_parser ice_fdir_parser_os = { diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index b145a3f..d891538 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -409,7 +409,7 @@ struct ice_hash_match_type ice_hash_type_list[] = { void **meta, struct rte_flow_error *error) { - int ret = 0; + int ret = -rte_errno; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -425,11 +425,11 @@ struct ice_hash_match_type ice_hash_type_list[] = { pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); if (!pattern_match_item) - return -rte_errno; + goto error; ret = ice_hash_check_inset(pattern, error); if (ret) - return -rte_errno; + goto error; /* Save protocol
[dpdk-dev] [PATCH v5] net/i40e: add PF MDD event handler
From: Zhu Tao Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message. Signed-off-by: Zhu Tao Acked-by: Qiming Yang --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 +- drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 92 insertions(+), 3 deletions(-) v6: - Change commit message v5: - Change commit message v4: - Change commit message - Rebase doc/guides/rel_notes/release_20_02.rst v3: - Change commit message diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index c7c34b62f..2bf11e8ca 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..a39f1 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -66,11 +66,13 @@ New Features * Added support for RSS using L3/L4 source/destination only. -* **Updated i40e driver to support L2TPv3 over IP flows.** +* **Updated i40e driver.** Updated the i40e PMD to support L2TPv3 over IP profiles which can be programmed by the dynamic device personalization (DDP) process. + Added PF support Malicious Device Drive event catch and notify. + * **Updated testpmd to support L2TPv3 over IP flows.** Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..95bfed4d9 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); +
[dpdk-dev] [PATCH v7] net/i40e: add PF MDD event handler
From: Zhu Tao Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message. Signed-off-by: Zhu Tao Acked-by: Qiming Yang --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 +- drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 92 insertions(+), 3 deletions(-) v7: - fix subject patch version v6: - Change commit message v5: - Change commit message v4: - Change commit message - Rebase doc/guides/rel_notes/release_20_02.rst v3: - Change commit message diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index c7c34b62f..2bf11e8ca 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..a39f1 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -66,11 +66,13 @@ New Features * Added support for RSS using L3/L4 source/destination only. -* **Updated i40e driver to support L2TPv3 over IP flows.** +* **Updated i40e driver.** Updated the i40e PMD to support L2TPv3 over IP profiles which can be programmed by the dynamic device personalization (DDP) process. + Added PF support Malicious Device Drive event catch and notify. + * **Updated testpmd to support L2TPv3 over IP flows.** Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..95bfed4d9 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E
[dpdk-dev] [PATCH v8] net/i40e: add PF MDD event handler
From: Zhu Tao Add warning and counter to handle the malicious driver detection event. When the hardware determines that a malicious driver on VF, this VF will become unworkable, the PF records and gives a warning message. Signed-off-by: Zhu Tao Acked-by: Qiming Yang --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 +- drivers/net/i40e/i40e_ethdev.c | 94 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 97 insertions(+), 3 deletions(-) v8: - Replace magic number with macros. v7: - fix subject patch version v6: - Change commit message v5: - Change commit message v4: - Change commit message - Rebase doc/guides/rel_notes/release_20_02.rst v3: - Change commit message diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index c7c34b62f..2bf11e8ca 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 1e83e659a..a39f1 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -66,11 +66,13 @@ New Features * Added support for RSS using L3/L4 source/destination only. -* **Updated i40e driver to support L2TPv3 over IP flows.** +* **Updated i40e driver.** Updated the i40e PMD to support L2TPv3 over IP profiles which can be programmed by the dynamic device personalization (DDP) process. + Added PF support Malicious Device Drive event catch and notify. + * **Updated testpmd to support L2TPv3 over IP flows.** Added support for L2TPv3 over IP rte_flow patterns to the testpmd diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index afb6f554b..caca3e88f 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,92 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ +#define I40E_MDD_CLEAR32 0x +#define I40E_MDD_CLEAR16 0x + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, I40E_MDD_CLEAR32); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, I40E_MDD_CLEAR32); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, I40E_MDD_CLEAR16); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_RE
[dpdk-dev] [PATCH v3] net/ixgbe: fix resource leak after thread exits normally
From: Zhu Tao When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Wait for the thread to finish without setting the timeout, wait until the thread finishes before returning. Normally, the thread will finish in a shorter time, and give a warning message if it hasn't finished in a longer time. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 46 +++- 1 file changed, 17 insertions(+), 29 deletions(-) v3 changes: 1. Wait for the thread to finish without setting the timeout, and the corresponding function name has also been modified. 2. Commit log. v2 changes: Commit log. diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..dac20a3 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -230,7 +230,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev, static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); static void *ixgbe_dev_setup_link_thread_handler(void *param); -static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev); +static void ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -2601,7 +2601,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2888,7 +2888,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4143,35 +4143,22 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return ret_val; } -/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ -static int +static void ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) { -#define DELAY_INTERVAL 100 /* 100ms */ -#define MAX_TIMEOUT90 /* 9s (90 * 100ms) in total */ +#define DELAY_INTERVAL 10 /* 10ms */ +#define WARNING_TIMEOUT900 /* 9s (900 * 10ms) in total */ struct ixgbe_adapter *ad = dev->data->dev_private; - int timeout = MAX_TIMEOUT; + int timeout = WARNING_TIMEOUT; - while (rte_atomic32_read(&ad->link_thread_running) && timeout) { + while (rte_atomic32_read(&ad->link_thread_running)) { msec_delay(DELAY_INTERVAL); timeout--; - } - - - return !!timeout; -} -static void -ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) -{ - struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; - - if (!ixgbe_dev_wait_setup_link_complete(dev)) { - pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); - rte_atomic32_clear(&ad->link_thread_running); - PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); + if (!timeout) { + timeout = WARNING_TIMEOUT; + PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!"); + } } } @@ -4186,6 +4173,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed; bool autoneg = false; + pthread_detach(pthread_self()); speed = hw->phy.autoneg_advertised; if (!speed) ixgbe_get_link_capabilities(hw, &speed, &autoneg); @@ -4282,8 +4270,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - if (ixgbe_dev_wait_setup_link_complete(dev) && - rte_atomic32_test_and_set(&ad->link_thread_running)) { +ixgbe_dev_wait_setup_link_complete(dev); + if (rte_atomic32_test_and_set(&ad->link_thread_running)) { if (rte_ctrl_thread_create(&ad->link_thread_tid, "ixgbe-link-handler",
[dpdk-dev] [PATCH v4] net/ixgbe: fix resource leak after thread exits normally
From: Zhu Tao When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Wait for the thread to finish without setting the timeout, wait until the thread finishes before returning. Normally, the thread will finish in a shorter time, and give a warning message if it hasn't finished in a longer time. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 46 +++- 1 file changed, 17 insertions(+), 29 deletions(-) v4 changes: Format codes. v3 changes: 1. Wait for the thread to finish without setting the timeout, and the corresponding function name has also been modified. 2. Commit log. v2 changes: Commit log. diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..9ad93c5 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -230,7 +230,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev, static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); static void *ixgbe_dev_setup_link_thread_handler(void *param); -static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev); +static void ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -2601,7 +2601,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2888,7 +2888,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4143,35 +4143,22 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return ret_val; } -/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ -static int +static void ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) { -#define DELAY_INTERVAL 100 /* 100ms */ -#define MAX_TIMEOUT90 /* 9s (90 * 100ms) in total */ +#define DELAY_INTERVAL 10 /* 10ms */ +#define WARNING_TIMEOUT900 /* 9s (900 * 10ms) in total */ struct ixgbe_adapter *ad = dev->data->dev_private; - int timeout = MAX_TIMEOUT; + int timeout = WARNING_TIMEOUT; - while (rte_atomic32_read(&ad->link_thread_running) && timeout) { + while (rte_atomic32_read(&ad->link_thread_running)) { msec_delay(DELAY_INTERVAL); timeout--; - } - - - return !!timeout; -} -static void -ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) -{ - struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; - - if (!ixgbe_dev_wait_setup_link_complete(dev)) { - pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); - rte_atomic32_clear(&ad->link_thread_running); - PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); + if (!timeout) { + timeout = WARNING_TIMEOUT; + PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!"); + } } } @@ -4186,6 +4173,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed; bool autoneg = false; + pthread_detach(pthread_self()); speed = hw->phy.autoneg_advertised; if (!speed) ixgbe_get_link_capabilities(hw, &speed, &autoneg); @@ -4282,8 +4270,8 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - if (ixgbe_dev_wait_setup_link_complete(dev) && - rte_atomic32_test_and_set(&ad->link_thread_running)) { + ixgbe_dev_wait_setup_link_complete(dev); + if (rte_atomic32_test_and_set(&ad->link_thread_running)) { if (rte_ctrl_thread_create(&ad->link_thread_tid, "ixgbe-link-handler"
[dpdk-dev] [PATCH v5] net/ixgbe: fix resource leak after thread exits normally
From: Zhu Tao When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Wait for the thread to finish with timeout argument(0 means that it will not return until link complete), wait until the thread finishes before returning. Normally, the thread will finish in a shorter time, and give a warning message if it hasn't finished in a longer time. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 57 +++- 1 file changed, 27 insertions(+), 30 deletions(-) V5 changes: Modify the definition of function ixgbe_dev_wait_setup_link_complete(), so that the caller can choose whether to block, etc. v4 changes: Format codes. v3 changes: 1. Wait for the thread to finish without setting the timeout, and the corresponding function name has also been modified. 2. Commit log. v2 changes: Commit log. diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..92788ee 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -230,7 +230,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev, static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); static void *ixgbe_dev_setup_link_thread_handler(void *param); -static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev); +static int ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -2601,7 +2601,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev, 0); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2888,7 +2888,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev, 0); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4143,36 +4143,32 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return ret_val; } -/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ +/* + * If @timeout_ms was 0, it means that it will not return until link complete. + * It returns 1 on complete, return 0 on timeout. + */ static int -ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) +ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms) { -#define DELAY_INTERVAL 100 /* 100ms */ -#define MAX_TIMEOUT90 /* 9s (90 * 100ms) in total */ +#define WARNING_TIMEOUT9000 /* 9s in total */ struct ixgbe_adapter *ad = dev->data->dev_private; - int timeout = MAX_TIMEOUT; + int timeout = timeout_ms ? WARNING_TIMEOUT : timeout_ms; - while (rte_atomic32_read(&ad->link_thread_running) && timeout) { - msec_delay(DELAY_INTERVAL); + while (rte_atomic32_read(&ad->link_thread_running)) { + msec_delay(1); timeout--; - } - - - return !!timeout; -} -static void -ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) -{ - struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; - - if (!ixgbe_dev_wait_setup_link_complete(dev)) { - pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); - rte_atomic32_clear(&ad->link_thread_running); - PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); + if (timeout_ms) { + if (!timeout) + return 0; + } else if (!timeout) { + /* It will not return until link complete */ + timeout = WARNING_TIMEOUT; + PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!"); + } } + + return 1; } static void * @@ -4186,6 +4182,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed; bool autoneg = false; + pthread_detach(pthread_self()); speed = hw->phy.autoneg_advertised; if (!speed) ixgbe_get_link_capabilities(hw, &speed, &autoneg); @@ -4282,8 +4279,8 @@ static int ixgbevf_de
[dpdk-dev] [PATCH v6] net/ixgbe: fix resource leak after thread exits normally
From: Zhu Tao When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Wait for the thread to finish with timeout argument(0 means that it will not return until link complete), wait until the thread finishes before returning. Normally, the thread will finish in a shorter time, and give a warning message if it hasn't finished in a longer time. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao Acked-by: Konstantin Ananyev --- drivers/net/ixgbe/ixgbe_ethdev.c | 57 +++- 1 file changed, 27 insertions(+), 30 deletions(-) V6 changes: Change code segment 'int timeout = timeout_ms ? WARNING_TIMEOUT : timeout_ms;' to 'uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT;'. V5 changes: Modify the definition of function ixgbe_dev_wait_setup_link_complete(), so that the caller can choose whether to block, etc. v4 changes: Format codes. v3 changes: 1. Wait for the thread to finish without setting the timeout, and the corresponding function name has also been modified. 2. Commit log. v2 changes: Commit log. diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..a3ae4d7 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -230,7 +230,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev, static void ixgbe_dev_interrupt_handler(void *param); static void ixgbe_dev_interrupt_delayed_handler(void *param); static void *ixgbe_dev_setup_link_thread_handler(void *param); -static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev); +static int ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms); static int ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, @@ -2601,7 +2601,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); /* Stop the link setup handler before resetting the HW. */ - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev, 0); /* disable uio/vfio intr/eventfd mapping */ rte_intr_disable(intr_handle); @@ -2888,7 +2888,7 @@ static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev) PMD_INIT_FUNC_TRACE(); - ixgbe_dev_cancel_link_thread(dev); + ixgbe_dev_wait_setup_link_complete(dev, 0); /* disable interrupts */ ixgbe_disable_intr(hw); @@ -4143,36 +4143,32 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, return ret_val; } -/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ +/* + * If @timeout_ms was 0, it means that it will not return until link complete. + * It returns 1 on complete, return 0 on timeout. + */ static int -ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) +ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms) { -#define DELAY_INTERVAL 100 /* 100ms */ -#define MAX_TIMEOUT90 /* 9s (90 * 100ms) in total */ +#define WARNING_TIMEOUT9000 /* 9s in total */ struct ixgbe_adapter *ad = dev->data->dev_private; - int timeout = MAX_TIMEOUT; + uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT; - while (rte_atomic32_read(&ad->link_thread_running) && timeout) { - msec_delay(DELAY_INTERVAL); + while (rte_atomic32_read(&ad->link_thread_running)) { + msec_delay(1); timeout--; - } - - - return !!timeout; -} -static void -ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) -{ - struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; - - if (!ixgbe_dev_wait_setup_link_complete(dev)) { - pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); - rte_atomic32_clear(&ad->link_thread_running); - PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); + if (timeout_ms) { + if (!timeout) + return 0; + } else if (!timeout) { + /* It will not return until link complete */ + timeout = WARNING_TIMEOUT; + PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!"); + } } + + return 1; } static void * @@ -4186,6 +4182,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed
[dpdk-dev] [PATCH] net/ixgbe: fix resource leak after thread exits normally
From: "Zhu, Tao" When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..f141ae4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4165,11 +4165,9 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) { struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; if (!ixgbe_dev_wait_setup_link_complete(dev)) { pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); rte_atomic32_clear(&ad->link_thread_running); PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); } @@ -4186,6 +4184,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed; bool autoneg = false; + pthread_detach(pthread_self()); speed = hw->phy.autoneg_advertised; if (!speed) ixgbe_get_link_capabilities(hw, &speed, &autoneg); -- 1.8.3.1
[dpdk-dev] [PATCH v2] net/ixgbe: fix resource leak after thread exits normally
From: Zhu Tao When the thread exits normally, pthread_join() is not called, which can result in a resource leak. Therefore, the thread is set to separation mode using function pthread_detach(), so that no program call pthread_join() is required to recycle, and when the thread exits, the system automatically reclaims resources. Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) v2 changes: commit log. diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 2c57976..f141ae4 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4165,11 +4165,9 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) { struct ixgbe_adapter *ad = dev->data->dev_private; - void *retval; if (!ixgbe_dev_wait_setup_link_complete(dev)) { pthread_cancel(ad->link_thread_tid); - pthread_join(ad->link_thread_tid, &retval); rte_atomic32_clear(&ad->link_thread_running); PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); } @@ -4186,6 +4184,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, u32 speed; bool autoneg = false; + pthread_detach(pthread_self()); speed = hw->phy.autoneg_advertised; if (!speed) ixgbe_get_link_capabilities(hw, &speed, &autoneg); -- 1.8.3.1
[dpdk-dev] [PATCH] mempool/octeontx2: fix compile issue
From: Tao Zhu Change the definition of C99 style to C90 style. compile log as below: otx2_mempool_ops.c: In function ‘otx2_npa_populate’: /dpdk/drivers/mempool/octeontx2/otx2_mempool_ops.c:790:2: error: \ ‘for’ loop initial declarations are only allowed in C99 mode for (int i = 0; i < OTX2_L1D_NB_SETS; i++) ^ /dpdk/drivers/mempool/octeontx2/otx2_mempool_ops.c:790:2: \ note: use option -std=c99 or -std=gnu99 to compile your code /dpdk/drivers/mempool/octeontx2/otx2_mempool_ops.c: At top level: cc1: error: unrecognized command line option \ "-Wno-address-of-packed-member" [-Werror] cc1: all warnings being treated as errors make[6]: *** [otx2_mempool_ops.o] Error 1 make[5]: *** [octeontx2] Error 2 make[4]: *** [mempool] Error 2 Fixes: 9ed8e95c ("mempool/octeontx2: optimize for L1D cache architecture") Signed-off-by: Tao Zhu --- drivers/mempool/octeontx2/otx2_mempool_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mempool/octeontx2/otx2_mempool_ops.c b/drivers/mempool/octeontx2/otx2_mempool_ops.c index 6b55447..ac2d618 100644 --- a/drivers/mempool/octeontx2/otx2_mempool_ops.c +++ b/drivers/mempool/octeontx2/otx2_mempool_ops.c @@ -754,6 +754,7 @@ size_t total_elt_sz; uint8_t set; size_t off; + int i; if (iova == RTE_BAD_IOVA) return -EINVAL; @@ -787,7 +788,7 @@ otx2_npa_dbg("requested objects %"PRIu64", possible objects %"PRIu64"", (uint64_t)max_objs, (uint64_t)(len / total_elt_sz)); otx2_npa_dbg("L1D set distribution :"); - for (int i = 0; i < OTX2_L1D_NB_SETS; i++) + for (i = 0; i < OTX2_L1D_NB_SETS; i++) otx2_npa_dbg("set[%d] : objects : %"PRIu64"", i, distribution[i]); -- 1.8.3.1
[dpdk-dev] [PATCH] net/ice: fix queue bind MSI-X interrupt error
From: Zhu Tao To bind a queue to an MSI-X interrupt, need to set some register. The register consists of many parts, each of which has several bits; therefore, the shift operator '<<' was used; so the operator '<' in the code should be '<<'. Old code adds 1 on even MSI-X interrupt vector index used by queue, resulting in interrupt mapping error. Fixes: 65dfc889d8 ("net/ice: support Rx queue interruption") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ice/ice_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 8e9369e0a..85ef83e92 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2605,9 +2605,9 @@ __vsi_queues_bind_intr(struct ice_vsi *vsi, uint16_t msix_vect, for (i = 0; i < nb_queue; i++) { /*do actual bind*/ val = (msix_vect & QINT_RQCTL_MSIX_INDX_M) | - (0 < QINT_RQCTL_ITR_INDX_S) | QINT_RQCTL_CAUSE_ENA_M; + (0 << QINT_RQCTL_ITR_INDX_S) | QINT_RQCTL_CAUSE_ENA_M; val_tx = (msix_vect & QINT_TQCTL_MSIX_INDX_M) | -(0 < QINT_TQCTL_ITR_INDX_S) | QINT_TQCTL_CAUSE_ENA_M; +(0 << QINT_TQCTL_ITR_INDX_S) | QINT_TQCTL_CAUSE_ENA_M; PMD_DRV_LOG(INFO, "queue %d is binding to vect %d", base_queue + i, msix_vect); -- 2.17.1
[dpdk-dev] [PATCH] net/ixgbe: fix link status inconsistencies
From: Zhu Tao Setting LINK UP or LINK DOWN is divided into two parts, with the main task done in a separate thread, which can take up to 9 seconds. If cancel the thread in execution, may cause state inconsistencies. Therefore, must wait for the previous setting to exit normally before setting the new state. Note: before using threads, use alarm to handle main tasks. When canceling alarm, the execution of alarm will not be interrupted. Fixes: 819d0d1d57 ("net/ixgbe: fix blocking system events") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ixgbe/ixgbe_ethdev.c | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 23b3f5b0c..2c5797635 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4143,16 +4143,35 @@ ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, return ret_val; } +/* return 1: setup complete, return 0: setup not complete, and wait timeout*/ +static int +ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev) +{ +#define DELAY_INTERVAL 100 /* 100ms */ +#define MAX_TIMEOUT90 /* 9s (90 * 100ms) in total */ + struct ixgbe_adapter *ad = dev->data->dev_private; + int timeout = MAX_TIMEOUT; + + while (rte_atomic32_read(&ad->link_thread_running) && timeout) { + msec_delay(DELAY_INTERVAL); + timeout--; + } + + + return !!timeout; +} + static void ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) { struct ixgbe_adapter *ad = dev->data->dev_private; void *retval; - if (rte_atomic32_read(&ad->link_thread_running)) { + if (!ixgbe_dev_wait_setup_link_complete(dev)) { pthread_cancel(ad->link_thread_tid); pthread_join(ad->link_thread_tid, &retval); rte_atomic32_clear(&ad->link_thread_running); + PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); } } @@ -4263,7 +4282,8 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev, if (link_up == 0) { if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) { intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; - if (rte_atomic32_test_and_set(&ad->link_thread_running)) { + if (ixgbe_dev_wait_setup_link_complete(dev) && + rte_atomic32_test_and_set(&ad->link_thread_running)) { if (rte_ctrl_thread_create(&ad->link_thread_tid, "ixgbe-link-handler", NULL, -- 2.17.1
[dpdk-dev] [DPDK] net/ice: fix hash flow segmentation fault
From: Zhu Tao Macro rte_errno is not a static value, so it needs to be updated in all error handling code. Patch 'dc36bd5dfd' mistakenly consider that rte_errno is a constant, which causes the unrecognized flow rule to be marked as recognition success. Later, when the code tried to parse the flow rule, a null pointer caused a segmentation fault. Fixes: dc36bd5dfd ("net/ice: fix flow FDIR/switch memory leak") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/ice/ice_hash.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index d891538bd..e5fb0f344 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -409,7 +409,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, void **meta, struct rte_flow_error *error) { - int ret = -rte_errno; + int ret = 0; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -424,12 +424,16 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss supported pattern and find matched pattern. */ pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); - if (!pattern_match_item) + if (!pattern_match_item) { + ret = -rte_errno; goto error; + } ret = ice_hash_check_inset(pattern, error); - if (ret) + if (ret) { + ret = -rte_errno; goto error; + } /* Save protocol header to rss_meta. */ *meta = rss_meta_ptr; @@ -439,8 +443,10 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss action. */ ret = ice_hash_parse_action(pattern_match_item, actions, meta, error); error: - if (ret) + if (ret) { + ret = -rte_errno; rte_free(rss_meta_ptr); + } rte_free(pattern_match_item); return ret; -- 2.17.1
[dpdk-dev] [PATCH v2] net/ice: fix hash flow segmentation fault
From: Zhu Tao Macro rte_errno is not a static value, so it needs to be updated in all error handling code. Patch 'dc36bd5dfdeb' mistakenly consider that rte_errno is a constant, which causes the unrecognized flow rule to be marked as recognition success. Later, when the code tried to parse the flow rule, a null pointer caused a segmentation fault. Fixes: dc36bd5dfdeb ("net/ice: fix flow FDIR/switch memory leak") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- v2 Changes: Commit message: Use 12 chars length of commit SHA in Fixes line. drivers/net/ice/ice_hash.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index d891538bd..e5fb0f344 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -409,7 +409,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, void **meta, struct rte_flow_error *error) { - int ret = -rte_errno; + int ret = 0; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -424,12 +424,16 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss supported pattern and find matched pattern. */ pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); - if (!pattern_match_item) + if (!pattern_match_item) { + ret = -rte_errno; goto error; + } ret = ice_hash_check_inset(pattern, error); - if (ret) + if (ret) { + ret = -rte_errno; goto error; + } /* Save protocol header to rss_meta. */ *meta = rss_meta_ptr; @@ -439,8 +443,10 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss action. */ ret = ice_hash_parse_action(pattern_match_item, actions, meta, error); error: - if (ret) + if (ret) { + ret = -rte_errno; rte_free(rss_meta_ptr); + } rte_free(pattern_match_item); return ret; -- 2.17.1
[dpdk-dev] [PATCH v3] net/ice: fix hash flow segmentation fault
From: Zhu Tao Macro rte_errno is not a static value, so it needs to be updated in all error handling code. Patch 'dc36bd5dfdeb' mistakenly consider that rte_errno is a constant, which causes the unrecognized flow rule to be marked as recognition success. Later, when the code tried to parse the flow rule, a null pointer caused a segmentation fault. Fixes: dc36bd5dfdeb ("net/ice: fix flow FDIR/switch memory leak") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- v3 Changes: Commit message: Use 12 chars length of commit SHA in Fixes line. Code: Delete redundant assignment codes. v2 Changes: Commit message: Use 12 chars length of commit SHA in Fixes line. drivers/net/ice/ice_hash.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c index d891538bd..0e9c3c4e5 100644 --- a/drivers/net/ice/ice_hash.c +++ b/drivers/net/ice/ice_hash.c @@ -409,7 +409,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, void **meta, struct rte_flow_error *error) { - int ret = -rte_errno; + int ret = 0; struct ice_pattern_match_item *pattern_match_item; struct rss_meta *rss_meta_ptr; @@ -424,8 +424,10 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad, /* Check rss supported pattern and find matched pattern. */ pattern_match_item = ice_search_pattern_match_item(pattern, array, array_len, error); - if (!pattern_match_item) + if (!pattern_match_item) { + ret = -rte_errno; goto error; + } ret = ice_hash_check_inset(pattern, error); if (ret) -- 2.17.1
[dpdk-dev] [PATCH] net/iavf: add TSO offload use basic path
From: Zhu Tao IAVF choices VECTOR TX path or Basic TX path by macro IAVF_NO_VECTOR_FLAGS. TSO offload only processed by Basic TX path. Fixes: 605c6f9ca5 ("net/avf: convert to new Rx and Tx offload API") Signed-off-by: Zhu Tao --- drivers/net/iavf/iavf_rxtx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index 225a0c4c4..60d02c521 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -28,6 +28,7 @@ DEV_TX_OFFLOAD_VLAN_INSERT | \ DEV_TX_OFFLOAD_SCTP_CKSUM | \ DEV_TX_OFFLOAD_UDP_CKSUM | \ + DEV_TX_OFFLOAD_TCP_TSO | \ DEV_TX_OFFLOAD_TCP_CKSUM) #define DEFAULT_TX_RS_THRESH 32 -- 2.17.1
[dpdk-dev] [PATCH] net/ice: add TSO offload use basic path
From: Zhu Tao ICE choices VECTOR TX path or Basic TX path by macro ICE_NO_VECTOR_FLAGS. TSO offload only processed by Basic TX path. Fixes: f88de4694d ("net/ice: support Tx SSE vector") Signed-off-by: Zhu Tao --- drivers/net/ice/ice_rxtx_vec_common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ice/ice_rxtx_vec_common.h b/drivers/net/ice/ice_rxtx_vec_common.h index 5e6f89642..6b57ff2ae 100644 --- a/drivers/net/ice/ice_rxtx_vec_common.h +++ b/drivers/net/ice/ice_rxtx_vec_common.h @@ -245,6 +245,7 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq) DEV_TX_OFFLOAD_VLAN_INSERT | \ DEV_TX_OFFLOAD_SCTP_CKSUM | \ DEV_TX_OFFLOAD_UDP_CKSUM | \ + DEV_TX_OFFLOAD_TCP_TSO | \ DEV_TX_OFFLOAD_TCP_CKSUM) static inline int -- 2.17.1
[dpdk-dev] [PATCH] net/i40e: add PF MDD event handler
From: Zhu Tao This patch adds a handler for malicious driver detection event. We just gave a warning log and a statistical count on the PF. Signed-off-by: Zhu Tao --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 ++ drivers/net/i40e/i40e_ethdev.c | 87 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index 38acf5906..539ea5c57 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 0eaa45a76..5f39006a4 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -56,6 +56,10 @@ New Features Also, make sure to start the actual text at the margin. = +* **Updated the Intel i40e driver.** + + Added PF support Malicious Device Drive event catch and notify. + Removed Items - diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5999c964b..87e638196 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,85 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); + PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n"); + } + } + + /* see if one of the VFs needs its hand slapped */ + for (i = 0; i < pf->vf_num && mdd_detected; i++) { + vf = &pf->vfs[i]; + reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i)); + if (reg & I40E_VP_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0x); + vf->num_mdd_events++; +
[dpdk-dev] [DPDK v2] net/i40e: add PF MDD event handler
From: Zhu Tao This patch adds a handler for malicious driver detection event. We just gave a warning log and a statistical count on the PF. Signed-off-by: Zhu Tao --- doc/guides/nics/i40e.rst | 1 + doc/guides/rel_notes/release_20_02.rst | 4 ++ drivers/net/i40e/i40e_ethdev.c | 89 +- drivers/net/i40e/i40e_ethdev.h | 1 + 4 files changed, 93 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index 38acf5906..539ea5c57 100644 --- a/doc/guides/nics/i40e.rst +++ b/doc/guides/nics/i40e.rst @@ -43,6 +43,7 @@ Features of the i40e PMD are: - Dynamic Device Personalization (DDP) - Queue region configuration - Virtual Function Port Representors +- Malicious Device Drive event catch and notify Prerequisites - diff --git a/doc/guides/rel_notes/release_20_02.rst b/doc/guides/rel_notes/release_20_02.rst index 0eaa45a76..5f39006a4 100644 --- a/doc/guides/rel_notes/release_20_02.rst +++ b/doc/guides/rel_notes/release_20_02.rst @@ -56,6 +56,10 @@ New Features Also, make sure to start the actual text at the margin. = +* **Updated the Intel i40e driver.** + + Added PF support Malicious Device Drive event catch and notify. + Removed Items - diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5999c964b..a66069b48 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) rte_free(info.msg_buf); } +static void +i40e_handle_mdd_event(struct rte_eth_dev *dev) +{ + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + bool mdd_detected = false; + struct i40e_pf_vf *vf; + uint32_t reg; + int i; + + /* find what triggered the MDD event */ + reg = I40E_READ_REG(hw, I40E_GL_MDET_TX); + if (reg & I40E_GL_MDET_TX_VALID_MASK) { + uint8_t pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> + I40E_GL_MDET_TX_PF_NUM_SHIFT; + uint16_t vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> + I40E_GL_MDET_TX_VF_NUM_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >> + I40E_GL_MDET_TX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> + I40E_GL_MDET_TX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on TX " + "queue %d PF number 0x%02x VF number 0x%02x device %s\n", + event, queue, pf_num, vf_num, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0x); + mdd_detected = true; + } + reg = I40E_READ_REG(hw, I40E_GL_MDET_RX); + if (reg & I40E_GL_MDET_RX_VALID_MASK) { + uint8_t func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> + I40E_GL_MDET_RX_FUNCTION_SHIFT; + uint8_t event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >> + I40E_GL_MDET_RX_EVENT_SHIFT; + uint16_t queue = ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> + I40E_GL_MDET_RX_QUEUE_SHIFT) - + hw->func_caps.base_queue; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event 0x%02x on RX " + "queue %d of function 0x%02x device %s\n", + event, queue, func, dev->data->name); + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0x); + mdd_detected = true; + } + + if (mdd_detected) { + reg = I40E_READ_REG(hw, I40E_PF_MDET_TX); + if (reg & I40E_PF_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0x); + PMD_DRV_LOG(WARNING, "TX driver issue detected on PF\n"); + } + reg = I40E_READ_REG(hw, I40E_PF_MDET_RX); + if (reg & I40E_PF_MDET_RX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0x); + PMD_DRV_LOG(WARNING, "RX driver issue detected on PF\n"); + } + } + + /* see if one of the VFs needs its hand slapped */ + for (i = 0; i < pf->vf_num && mdd_detected; i++) { + vf = &pf->vfs[i]; + reg = I40E_READ_REG(hw, I40E_VP_MDET_TX(i)); + if (reg & I40E_VP_MDET_TX_VALID_MASK) { + I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0x); + vf->num_mdd_events++; +
[dpdk-dev] [PATCH] examples/ipsec-secgw: add parameter --mtu parse option
From: Zhu Tao This patch add parameter --mtu parse key and enumeration value. Signed-off-by: Zhu Tao --- examples/ipsec-secgw/ipsec-secgw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index b1ecbb975..05fffa967 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -159,6 +159,7 @@ static const struct option lgopts[] = { {CMD_LINE_OPT_RX_OFFLOAD, 1, 0, CMD_LINE_OPT_RX_OFFLOAD_NUM}, {CMD_LINE_OPT_TX_OFFLOAD, 1, 0, CMD_LINE_OPT_TX_OFFLOAD_NUM}, {CMD_LINE_OPT_REASSEMBLE, 1, 0, CMD_LINE_OPT_REASSEMBLE_NUM}, + {CMD_LINE_OPT_MTU, 1, 0, CMD_LINE_OPT_MTU_NUM}, {NULL, 0, 0, 0} }; -- 2.17.1
[dpdk-dev] [PATCH] net/i40e: fix request queue fail in VF
From: Zhu Tao When the VF configuration is larger than the number of queues reserved by PF, VF sends the request queue command through admin queue. When PF received this command, it may reset the VF and send a notification before resetting. If this notification is read by the timed task alarm, Task request queue will lost notification. This patch Mark vf_reset, pend_msg flag just as task request queue has received notification in task alarm. Signed-off-by: Zhu Tao --- drivers/net/i40e/i40e_ethdev_vf.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 5be32b069..86dfda1c0 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1332,6 +1332,10 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev, uint8_t *msg, PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event"); _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL); + if (vf->vf_reset == false) { + vf->vf_reset = true; + vf->pend_msg |= PFMSG_RESET_IMPENDING; + } break; case VIRTCHNL_EVENT_LINK_CHANGE: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event"); -- 2.17.1
[dpdk-dev] [PATCH v2] net/i40e: fix request queue fail in VF
From: Zhu Tao When the VF configuration is larger than the number of queues reserved by PF, VF sends the request queue command through admin queue. When PF received this command, it may reset the VF and send a notification before resetting. If this notification is read by the timed task alarm, Task request queue will lost notification. This patch Mark vf_reset, pend_msg flag just as task request queue has received notification in task alarm. Fixes: 864a800d70 ("net/i40e: remove VF interrupt handler") Fixes: ee653bd800 ("net/i40e: determine number of queues per VF at run time") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/i40e/i40e_ethdev_vf.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 5be32b069..3b9740c08 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1332,6 +1332,10 @@ i40evf_handle_pf_event(struct rte_eth_dev *dev, uint8_t *msg, PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event"); _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL); + if (!vf->vf_reset) { + vf->vf_reset = true; + vf->pend_msg |= PFMSG_RESET_IMPENDING; + } break; case VIRTCHNL_EVENT_LINK_CHANGE: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event"); -- 2.17.1
[dpdk-dev] [PATCH v3] net/i40e: fix request queue fail in VF
From: Zhu Tao When the VF configuration is larger than the number of queues reserved by PF, VF sends the request queue command through admin queue. When PF received this command, it may reset the VF and send a notification before resetting. If this notification is read by the timed task alarm, Task request queue will lost notification. This patch prevents two tasks from running simultaneously. Fixes: 864a800d70 ("net/i40e: remove VF interrupt handler") Fixes: ee653bd800 ("net/i40e: determine number of queues per VF at run time") Cc: sta...@dpdk.org Signed-off-by: Zhu Tao --- drivers/net/i40e/i40e_ethdev_vf.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 5be32b069..34aaaf207 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -140,6 +140,8 @@ static int i40evf_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *mc_addr_set, uint32_t nb_mc_addr); +static void +i40evf_dev_alarm_handler(void *param); /* Default hash key buffer for RSS */ static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1]; @@ -1051,10 +1053,14 @@ i40evf_request_queues(struct rte_eth_dev *dev, uint16_t num) args.in_args_size = sizeof(vfres); args.out_buffer = vf->aq_resp; args.out_size = I40E_AQ_BUF_SZ; + + rte_eal_alarm_cancel(i40evf_dev_alarm_handler, dev); err = i40evf_execute_vf_cmd(dev, &args); if (err) PMD_DRV_LOG(ERR, "fail to execute command OP_REQUEST_QUEUES"); + rte_eal_alarm_set(I40EVF_ALARM_INTERVAL, + i40evf_dev_alarm_handler, dev); return err; } -- 2.17.1
[dpdk-dev] [PATCH] net/i40e: qinq strip is not supported by i40e
From: Zhu Tao Qinq strip is not supported by i40e. When user tries to turn on QinQ strip, the driver gives unsupported return value and log. Signed-off-by: Zhu Tao --- drivers/net/i40e/i40e_ethdev.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 77a46832c..ed8cbd849 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -3847,6 +3847,11 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask) struct i40e_vsi *vsi = pf->main_vsi; struct rte_eth_rxmode *rxmode; + if (mask & ETH_QINQ_STRIP_MASK) { + PMD_DRV_LOG(ERR, "Strip qinq is not supported."); + return -ENOTSUP; + } + rxmode = &dev->data->dev_conf.rxmode; if (mask & ETH_VLAN_FILTER_MASK) { if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER) -- 2.17.1
[dpdk-dev] [DPDK] net/ice: set vlan tpid is not supported by ice
From: Zhu Tao Set vlan tpid is not supported by ice hardware. Delete driver code that doesn't work. Signed-off-by: Zhu Tao --- drivers/net/ice/ice_ethdev.c | 54 1 file changed, 54 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index d74675842..ec0234091 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -69,9 +69,6 @@ static int ice_dev_set_link_down(struct rte_eth_dev *dev); static int ice_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int ice_vlan_offload_set(struct rte_eth_dev *dev, int mask); -static int ice_vlan_tpid_set(struct rte_eth_dev *dev, -enum rte_vlan_type vlan_type, -uint16_t tpid); static int ice_rss_reta_update(struct rte_eth_dev *dev, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t reta_size); @@ -156,7 +153,6 @@ static const struct eth_dev_ops ice_eth_dev_ops = { .mac_addr_remove = ice_macaddr_remove, .vlan_filter_set = ice_vlan_filter_set, .vlan_offload_set = ice_vlan_offload_set, - .vlan_tpid_set= ice_vlan_tpid_set, .reta_update = ice_rss_reta_update, .reta_query = ice_rss_reta_query, .rss_hash_update = ice_rss_hash_update, @@ -3340,56 +3336,6 @@ ice_vlan_offload_set(struct rte_eth_dev *dev, int mask) return 0; } -static int -ice_vlan_tpid_set(struct rte_eth_dev *dev, - enum rte_vlan_type vlan_type, - uint16_t tpid) -{ - struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint64_t reg_r = 0, reg_w = 0; - uint16_t reg_id = 0; - int ret = 0; - int qinq = dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_VLAN_EXTEND; - - switch (vlan_type) { - case ETH_VLAN_TYPE_OUTER: - if (qinq) - reg_id = 3; - else - reg_id = 5; - break; - case ETH_VLAN_TYPE_INNER: - if (qinq) { - reg_id = 5; - } else { - PMD_DRV_LOG(ERR, - "Unsupported vlan type in single vlan."); - return -EINVAL; - } - break; - default: - PMD_DRV_LOG(ERR, "Unsupported vlan type %d", vlan_type); - return -EINVAL; - } - reg_r = ICE_READ_REG(hw, GL_SWT_L2TAGCTRL(reg_id)); - PMD_DRV_LOG(DEBUG, "Debug read from ICE GL_SWT_L2TAGCTRL[%d]: " - "0x%08"PRIx64"", reg_id, reg_r); - - reg_w = reg_r & (~(GL_SWT_L2TAGCTRL_ETHERTYPE_M)); - reg_w |= ((uint64_t)tpid << GL_SWT_L2TAGCTRL_ETHERTYPE_S); - if (reg_r == reg_w) { - PMD_DRV_LOG(DEBUG, "No need to write"); - return 0; - } - - ICE_WRITE_REG(hw, GL_SWT_L2TAGCTRL(reg_id), reg_w); - PMD_DRV_LOG(DEBUG, "Debug write 0x%08"PRIx64" to " - "ICE GL_SWT_L2TAGCTRL[%d]", reg_w, reg_id); - - return ret; -} - static int ice_get_rss_lut(struct ice_vsi *vsi, uint8_t *lut, uint16_t lut_size) { -- 2.17.1
[dpdk-dev] [DPDK] app/testpmd: fix unused variable compile error
From: Zhu Tao This minor patch fixes unused variable ‘ret’ compile error When CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC was selected. Fixes: f5267e485a2a ("app/testpmd: check status of getting ethdev info") Signed-off-by: Zhu Tao --- app/test-pmd/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 957c61fbe..a3b6cbd08 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1649,10 +1649,10 @@ ring_rx_descriptor_display(const struct rte_memzone *ring_mz, #endif uint16_t desc_id) { - int ret; struct igb_ring_desc_16_bytes *ring = (struct igb_ring_desc_16_bytes *)ring_mz->addr; #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC + int ret; struct rte_eth_dev_info dev_info; ret = eth_dev_info_get_print_err(port_id, &dev_info); -- 2.17.1
[dpdk-dev] [PATCH v2] app/testpmd: fix unused variable compile error
From: Zhu Tao This minor patch fixes unused variable ‘ret’ compile error When CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC was selected. Fixes: f5267e485a2a ("app/testpmd: check status of getting ethdev info") Signed-off-by: Zhu Tao --- app/test-pmd/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 957c61fbe..a3b6cbd08 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1649,10 +1649,10 @@ ring_rx_descriptor_display(const struct rte_memzone *ring_mz, #endif uint16_t desc_id) { - int ret; struct igb_ring_desc_16_bytes *ring = (struct igb_ring_desc_16_bytes *)ring_mz->addr; #ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC + int ret; struct rte_eth_dev_info dev_info; ret = eth_dev_info_get_print_err(port_id, &dev_info); -- 2.17.1