misc updates and fixes for hns3 PMD driver
v2 cover misc updates and fixes for hns3 PMD driver
This series are updates and fixes for hns3 PMD driver.
Chengchang Tang (3):
net/hns3: remove unnecessary restriction on setting VF's MTU net/hns3: support promiscuous and allmulticast mode for VF net/hns3: fix promiscuous mode for PF
Hongbo Zheng (1):
net/hns3: support TCP segment offload
Wei Hu (Xavier) (1):
net/hns3: fix wrong Tx interrupt when enabling Rx interrupt
doc/guides/nics/features/hns3.ini | 1 + doc/guides/nics/features/hns3_vf.ini | 3 + doc/guides/nics/hns3.rst | 1 + drivers/net/hns3/hns3_cmd.h | 31 ++- drivers/net/hns3/hns3_ethdev.c | 162 +++++++++++--- drivers/net/hns3/hns3_ethdev.h | 7 +- drivers/net/hns3/hns3_ethdev_vf.c | 315 +++++++++++++++++++++++---- drivers/net/hns3/hns3_mbx.c | 23 ++ drivers/net/hns3/hns3_mbx.h | 2 + drivers/net/hns3/hns3_regs.h | 13 +- drivers/net/hns3/hns3_rxtx.c | 306 +++++++++++++++++++++++--- drivers/net/hns3/hns3_rxtx.h | 5 +- 12 files changed, 754 insertions(+), 115 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/5 net/hns3: support TCP segment offload
From: Hongbo Zheng <[email protected]>
This patch adds TCP segment offload support for hns3 PMD driver.
--- doc/guides/nics/features/hns3.ini | 1 + doc/guides/nics/features/hns3_vf.ini | 1 + doc/guides/nics/hns3.rst | 1 + drivers/net/hns3/hns3_ethdev.c | 4 + drivers/net/hns3/hns3_ethdev.h | 6 +- drivers/net/hns3/hns3_ethdev_vf.c | 4 + drivers/net/hns3/hns3_rxtx.c | 258 +++++++++++++++++++++++++-- 7 files changed, 259 insertions(+), 16 deletions(-)
doc/guides/nics/features/hns3.ini +1 -0
@@ -8,6 +8,7 @@ Link status = Y Rx interrupt = Y MTU update = Y Jumbo frame = Y +TSO = Y Promiscuous mode = Y Allmulticast mode = Y Unicast MAC filter = Y
doc/guides/nics/features/hns3_vf.ini +1 -0
@@ -8,6 +8,7 @@ Link status = Y Rx interrupt = Y MTU update = Y Jumbo frame = Y +TSO = Y Unicast MAC filter = Y Multicast MAC filter = Y RSS hash = Y
doc/guides/nics/hns3.rst +1 -0
@@ -17,6 +17,7 @@ Features of the HNS3 PMD are: - Receive Side Scaling (RSS) - Packet type information - Checksum offload +- TSO offload - Promiscuous mode - Multicast mode - Port hardware statistics
drivers/net/hns3/hns3_ethdev.c +4 -0
@@ -2256,6 +2256,10 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)DEV_TX_OFFLOAD_VLAN_INSERT |DEV_TX_OFFLOAD_QINQ_INSERT |DEV_TX_OFFLOAD_MULTI_SEGS | +DEV_TX_OFFLOAD_TCP_TSO | +DEV_TX_OFFLOAD_VXLAN_TNL_TSO | +DEV_TX_OFFLOAD_GRE_TNL_TSO | +DEV_TX_OFFLOAD_GENEVE_TNL_TSO | info->tx_queue_offload_capa); info->rx_desc_lim = (struct rte_eth_desc_lim ) {
drivers/net/hns3/hns3_ethdev.h +5 -1
@@ -31,10 +31,14 @@#define HNS3_MC_MACADDR_NUM 128#define HNS3_MAX_BD_SIZE 65535 -#define HNS3_MAX_TX_BD_PER_PKT 8 +#define HNS3_MAX_NON_TSO_BD_PER_PKT 8 +#define HNS3_MAX_TSO_BD_PER_PKT 63#define HNS3_MAX_FRAME_LEN 9728#define HNS3_VLAN_TAG_SIZE 4#define HNS3_DEFAULT_RX_BUF_LEN 2048 +#define HNS3_MAX_BD_PAYLEN (1024 * 1024 - 1) +#define HNS3_MAX_TSO_HDR_SIZE 512 +#define HNS3_MAX_TSO_HDR_BD_NUM 3#define HNS3_ETH_OVERHEAD \ (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + HNS3_VLAN_TAG_SIZE * 2)
drivers/net/hns3/hns3_ethdev_vf.c +4 -0
@@ -592,6 +592,10 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)DEV_TX_OFFLOAD_VLAN_INSERT |DEV_TX_OFFLOAD_QINQ_INSERT |DEV_TX_OFFLOAD_MULTI_SEGS | +DEV_TX_OFFLOAD_TCP_TSO | +DEV_TX_OFFLOAD_VXLAN_TNL_TSO | +DEV_TX_OFFLOAD_GRE_TNL_TSO | +DEV_TX_OFFLOAD_GENEVE_TNL_TSO | info->tx_queue_offload_capa); info->rx_desc_lim = (struct rte_eth_desc_lim ) {
drivers/net/hns3/hns3_rxtx.c +243 -15
320 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v2 2/5 net/hns3: fix wrong Tx interrupt when enabling Rx interrupt
In reply to Wei Hu (Xavier)From: "Wei Hu (Xavier)" <[email protected]>
Currently, when receiving and transmitting packets based on hns3 network engine there are probably unexpected and redundant Tx interrupts if Rx interrupt is enabled.
The root cause as below:
Tx and Rx queues with the same number share the interrupt vector in hns3 network engine, and in this case there are the residual hardware mapping relationship configuration between queue and interrupt vector configured in hns3 kernel ethdev driver.
We should clear the all hardware mapping relationship configrations in the initialization. Because of the hardware constraints, we have to implement clearing the relationship by binding all queues to the last interrupt vector and reserving the last interrupt vector, this method results in a decrease of the maximum queues when upper applications call the rte_eth_dev_configure API function to enable Rx interrupt.
--- drivers/net/hns3/hns3_cmd.h | 31 +++-- drivers/net/hns3/hns3_ethdev.c | 117 ++++++++++++++++--- drivers/net/hns3/hns3_ethdev.h | 1 + drivers/net/hns3/hns3_ethdev_vf.c | 180 ++++++++++++++++++++++++------ drivers/net/hns3/hns3_regs.h | 13 ++- drivers/net/hns3/hns3_rxtx.c | 48 ++++++-- drivers/net/hns3/hns3_rxtx.h | 5 +- 7 files changed, 326 insertions(+), 69 deletions(-)
drivers/net/hns3/hns3_cmd.h +24 -7
@@ -79,6 +79,7 @@ enum hns3_opcode_type {HNS3_OPC_GBL_RST_STATUS =0x0021 ,HNS3_OPC_QUERY_FUNC_STATUS =0x0022 ,HNS3_OPC_QUERY_PF_RSRC =0x0023 , +HNS3_OPC_QUERY_VF_RSRC =0x0024 ,HNS3_OPC_GET_CFG_PARAM =0x0025 , HNS3_OPC_PF_RST_DONE = 0x0026,
@@ -337,8 +338,9 @@ struct hns3_func_status_cmd {uint8_t rsv[2 ]; }; -#define HNS3_PF_VEC_NUM_S 0 -#define HNS3_PF_VEC_NUM_M GENMASK(7, 0) +#define HNS3_VEC_NUM_S 0 +#define HNS3_VEC_NUM_M GENMASK(7, 0) +#define HNS3_MIN_VECTOR_NUM 2/* one for msi-x, another for IO */ struct hns3_pf_res_cmd {uint16_t tqp_num;uint16_t buf_size;
@@ -351,6 +353,15 @@ struct hns3_pf_res_cmd {uint32_t rsv[2 ]; }; +struct hns3_vf_res_cmd { +uint16_t tqp_num; +uint16_t reserved; +uint16_t msixcap_localid_ba_nic; +uint16_t msixcap_localid_ba_rocee; +uint16_t vf_intr_vector_number; +uint16_t rsv[7 ]; +}; +#define HNS3_UMV_SPC_ALC_B 0struct hns3_umv_spc_alc_cmd {uint8_t allocate;
@@ -677,13 +688,19 @@ struct hns3_tqp_map_cmd {uint8_t rsv[18 ]; }; -#define HNS3_RING_TYPE_B 0 -#define HNS3_RING_TYPE_TX 0 -#define HNS3_RING_TYPE_RX 1 +enum hns3_ring_type { +HNS3_RING_TYPE_TX , +HNS3_RING_TYPE_RX +}; + +enum hns3_int_gl_idx { +HNS3_RING_GL_RX , +HNS3_RING_GL_TX , +HNS3_RING_GL_IMMEDIATE =3 +}; +#define HNS3_RING_GL_IDX_S 0#define HNS3_RING_GL_IDX_M GENMASK(1, 0) -#define HNS3_RING_GL_RX 0 -#define HNS3_RING_GL_TX 1#define HNS3_VECTOR_ELEMENTS_PER_CMD 10
drivers/net/hns3/hns3_ethdev.c +102 -15
179 lines not on this page · raw message
drivers/net/hns3/hns3_ethdev.h +1 -0
@@ -357,6 +357,7 @@ struct hns3_hw {uint16_t num_msi;uint16_t total_tqps_num;/* total task queue pairs of this PF */ uint16_t tqps_num;/* num task queue pairs of this function */ +uint16_t intr_tqps_num;/* num queue pairs mapping interrupt */ uint16_t rss_size_max;/* HW defined max RSS task queue */ uint16_t rx_buf_len;uint16_t num_tx_desc;/* desc num of per tx queue */
drivers/net/hns3/hns3_ethdev_vf.c +147 -33
229 lines not on this page · raw message
drivers/net/hns3/hns3_regs.h +10 -3
@@ -83,9 +83,6 @@#define HNS3_RING_EN_B 0 -#define HNS3_VECTOR_REG_OFFSET 0x4 -#define HNS3_VECTOR_VF_OFFSET 0x100000 -#define HNS3_TQP_REG_OFFSET 0x80000#define HNS3_TQP_REG_SIZE 0x200
@@ -97,6 +94,16 @@#define HNS3_TQP_INTR_RL_REG 0x20900#define HNS3_TQP_INTR_REG_SIZE 4 +#define HNS3_TQP_INTR_GL_MAX 0x1FE0 +#define HNS3_TQP_INTR_GL_DEFAULT 20 +#define HNS3_TQP_INTR_RL_MAX 0xEC +#define HNS3_TQP_INTR_RL_ENABLE_MASK 0x40 +#define HNS3_TQP_INTR_RL_DEFAULT 0 + +/* gl_usec convert to hardware count, as writing each 1 represents 2us */ +#define HNS3_GL_USEC_TO_REG (gl_usec) ((gl_usec) >> 1) +/* rl_usec convert to hardware count, as writing each 1 represents 4us */ +#define HNS3_RL_USEC_TO_REG (rl_usec) ((rl_usec) >> 2)int hns3_get_regs (struct rte_eth_dev *eth_dev,struct rte_dev_reg_info *regs);#endif /* _HNS3_REGS_H_ */
drivers/net/hns3/hns3_rxtx.c +38 -10
93 lines not on this page · raw message
drivers/net/hns3/hns3_rxtx.h +4 -1
@@ -320,7 +320,10 @@ uint16_t hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);const uint32_t *hns3_dev_supported_ptypes_get (struct rte_eth_dev *dev);void hns3_set_rxtx_function (struct rte_eth_dev *eth_dev); -void hns3_tqp_intr_enable (struct hns3_hw *hw,uint16_t tpq_int_num,bool en); +void hns3_set_queue_intr_gl (struct hns3_hw *hw,uint16_t queue_id, +uint8_t gl_idx,uint16_t gl_value); +void hns3_set_queue_intr_rl (struct hns3_hw *hw,uint16_t queue_id, +uint16_t rl_value);int hns3_set_fake_rx_or_tx_queues (struct rte_eth_dev *dev,uint16_t nb_rx_q,uint16_t nb_tx_q);
Signature · 1 line
2.23.0
PATCH v2 3/5 net/hns3: remove unnecessary restriction on setting VF's MTU
In reply to Wei Hu (Xavier)From: Chengchang Tang <[email protected]>
The hns3 PF/VF devices on the same port share the hardware MTU configuration. Currently, we send mailbox to inform hns3 PF kernel ethdev driver to finish hardware MTU configuration in hns3 VF PMD driver, there is no need to stop the port for hns3 VF device, and the MTU value issued by hns3 VF PMD driver must be less than or equal to PF's MTU.
--- drivers/net/hns3/hns3_ethdev_vf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/hns3/hns3_ethdev_vf.c +8 -6
@@ -619,12 +619,14 @@ hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)uint32_t frame_size = mtu +HNS3_ETH_OVERHEAD ;int ret; -if (dev->data->dev_started) { -hns3_err (hw,"Failed to set mtu, port %u must be stopped " -"before configuration" , dev->data->port_id); -return -EBUSY ; - } - +/* +* The hns3 PF/VF devices on the same port share the hardware MTU +* configuration. Currently, we send mailbox to inform hns3 PF kernel +* ethdev driver to finish hardware MTU configuration in hns3 VF PMD +* driver, there is no need to stop the port for hns3 VF device, and the +* MTU value issued by hns3 VF PMD driver must be less than or equal to +* PF's MTU. +*/ if (rte_atomic16_read (&hw->reset.resetting)) {hns3_err (hw,"Failed to set mtu during resetting" );return -EIO ;
Signature · 1 line
2.23.0
PATCH v2 4/5 net/hns3: support promiscuous and allmulticast mode for VF
In reply to Wei Hu (Xavier)From: Chengchang Tang <[email protected]>
Currently, we only support VF device is bound to vfio_pci or igb_uio and then driven by DPDK driver when PF is driven by kernel mode hns3 ethdev driver, VF is not supported when PF is driven by hns3 DPDK driver.
This patch adds promiscuous and allmulticast mode support for hns3 VF PMD driver.
1) The promiscuous/allmulticast mode can be configured successfully only based on the trusted VF device. If based on the non trusted VF device, configuring promiscuous/allmulticast mode will fail. The hns3 VF device can be confiruged as trusted device by hns3 PF kernel ethdev driver on the host by "ip link set <eth num> vf <vf id> turst on" command.
2) After the promiscuous mode is configured successfully, hns3 VF PMD driver can receive the ingress and outgoing traffic. In the words, all the ingress packets, all the packets sent from the PF and other VFs on the same physical port.
3) Note: Because of the hardware constraints, By default vlan filter is enabled and couldn't be turned off based on VF device, so vlan filter is still effective even in promiscuous mode. If upper applications don't call rte_eth_dev_vlan_filter API function to set vlan based on VF device, hns3 VF PMD driver will can't receive the packets with vlan tag in promiscuoue mode.
---
v1 -> v2:
Add Promiscuous and Allmulticast mode to hns3_vf.ini.
--- doc/guides/nics/features/hns3_vf.ini | 2 + drivers/net/hns3/hns3_ethdev_vf.c | 117 +++++++++++++++++++++++++-- drivers/net/hns3/hns3_mbx.c | 23 ++++++ drivers/net/hns3/hns3_mbx.h | 2 + 4 files changed, 139 insertions(+), 5 deletions(-)
doc/guides/nics/features/hns3_vf.ini +2 -0
@@ -9,6 +9,8 @@ Rx interrupt = Y MTU update = Y Jumbo frame = Y TSO = Y +Promiscuous mode = Y +Allmulticast mode = Y Unicast MAC filter = Y Multicast MAC filter = Y RSS hash = Y
drivers/net/hns3/hns3_ethdev_vf.c +112 -5
169 lines not on this page · raw message
drivers/net/hns3/hns3_mbx.c +23 -0
@@ -324,6 +324,21 @@ hns3_handle_link_change_event(struct hns3_hw *hw,hns3_update_link_status (hw); } +static void +hns3_handle_promisc_info (struct hns3_hw *hw,uint16_t promisc_en) +{ +if (!promisc_en) { +/* +* When promisc/allmulti mode is closed by the hns3 PF kernel +* ethdev driver for untrusted, modify VF's related status. +*/ +hns3_warn (hw,"Promisc mode will be closed by host for being " +"untrusted." ); + hw->data->promiscuous =0 ; + hw->data->all_multicast =0 ; + } +} +void hns3_dev_handle_mbx_msg (struct hns3_hw *hw) {
@@ -380,6 +395,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)case HNS3_MBX_PUSH_LINK_STATUS :hns3_handle_link_change_event (hw, req);break ; +case HNS3_MBX_PUSH_PROMISC_INFO : +/* +* When the trust status of VF device changed by the +* hns3 PF kernel driver, VF driver will receive this +* mailbox message from PF driver. +*/ +hns3_handle_promisc_info (hw, req->msg[1 ]); +break ;default : hns3_err(hw, "VF received unsupported(%d) mbx msg from PF",
drivers/net/hns3/hns3_mbx.h +2 -0
@@ -40,6 +40,8 @@ enum HNS3_MBX_OPCODE {HNS3_MBX_SET_MTU ,/* (VF -> PF) set mtu */ HNS3_MBX_GET_QID_IN_PF ,/* (VF -> PF) get queue id in pf */ +HNS3_MBX_PUSH_PROMISC_INFO =36 ,/* (PF -> VF) push vf promisc info */ +HNS3_MBX_HANDLE_VF_TBL =38 ,/* (VF -> PF) store/clear hw cfg tbl */ HNS3_MBX_GET_RING_VECTOR_MAP ,/* (VF -> PF) get ring-to-vector map */ HNS3_MBX_PUSH_LINK_STATUS = 201, /* (IMP -> PF) get port link status */
Signature · 1 line
2.23.0
PATCH v2 5/5 net/hns3: fix promiscuous mode for PF
In reply to Wei Hu (Xavier)From: Chengchang Tang <[email protected]>
Currently, when promiscuous mode is enabled, it is just allowed to accept all the unicast and broadcast packets in hns3 PF PMD driver. It should also be able to receive multicast packets.
--- drivers/net/hns3/hns3_ethdev.c | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-)
drivers/net/hns3/hns3_ethdev.c +22 -19
@@ -3649,7 +3649,7 @@ hns3_cmd_set_promisc_mode(struct hns3_hw *hw, struct hns3_promisc_param *param) ret =hns3_cmd_send (hw, &desc,1 );if (ret) -PMD_INIT_LOG (ERR ,"Set promisc mode fail, status is %d" , ret); +PMD_INIT_LOG (ERR ,"Set promisc mode fail, ret = %d" , ret);return ret; }
@@ -3702,14 +3702,14 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev) {struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -bool en_mc_pmc = (dev->data->all_multicast ==1 ) ? true : false;int ret;rte_spinlock_lock (&hw->lock); - ret =hns3_set_promisc_mode (hw, true, en_mc_pmc); + ret =hns3_set_promisc_mode (hw, true, true);rte_spinlock_unlock (&hw->lock);if (ret) -hns3_err (hw,"Failed to enable promiscuous mode: %d" , ret); +hns3_err (hw,"Failed to enable promiscuous mode, ret = %d" , + ret);return ret; }
@@ -3717,17 +3717,18 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev)static int hns3_dev_promiscuous_disable (struct rte_eth_dev *dev) { +bool allmulti = dev->data->all_multicast ? true : false;struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -bool en_mc_pmc = (dev->data->all_multicast ==1 ) ? true : false;int ret;/* If now in all_multicast mode, must remain in all_multicast mode. */ rte_spinlock_lock (&hw->lock); - ret =hns3_set_promisc_mode (hw, false, en_mc_pmc); + ret =hns3_set_promisc_mode (hw, false, allmulti);rte_spinlock_unlock (&hw->lock);if (ret) -hns3_err (hw,"Failed to disable promiscuous mode: %d" , ret); +hns3_err (hw,"Failed to disable promiscuous mode, ret = %d" , + ret);return ret; }
@@ -3737,14 +3738,17 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev) {struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -bool en_uc_pmc = (dev->data->promiscuous ==1 ) ? true : false;int ret; +if (dev->data->promiscuous) +return 0 ; +rte_spinlock_lock (&hw->lock); - ret =hns3_set_promisc_mode (hw, en_uc_pmc, true); + ret =hns3_set_promisc_mode (hw, false, true);rte_spinlock_unlock (&hw->lock);if (ret) -hns3_err (hw,"Failed to enable allmulticast mode: %d" , ret); +hns3_err (hw,"Failed to enable allmulticast mode, ret = %d" , + ret);return ret; }
@@ -3754,18 +3758,18 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev) {struct hns3_adapter *hns = dev->data->dev_private;struct hns3_hw *hw = &hns->hw; -bool en_uc_pmc = (dev->data->promiscuous ==1 ) ? true : false;int ret;/* If now in promiscuous mode, must remain in all_multicast mode. */ -if (dev->data->promiscuous ==1 ) +if (dev->data->promiscuous)return 0 ;rte_spinlock_lock (&hw->lock); - ret =hns3_set_promisc_mode (hw, en_uc_pmc, false); + ret =hns3_set_promisc_mode (hw, false, false);rte_spinlock_unlock (&hw->lock);if (ret) -hns3_err (hw,"Failed to disable allmulticast mode: %d" , ret); +hns3_err (hw,"Failed to disable allmulticast mode, ret = %d" , + ret);return ret; }
@@ -3774,13 +3778,12 @@ static int hns3_dev_promisc_restore(struct hns3_adapter *hns) {struct hns3_hw *hw = &hns->hw; -bool en_mc_pmc; -bool en_uc_pmc; +bool allmulti = hw->data->all_multicast ? true : false; - en_uc_pmc = (hw->data->promiscuous ==1 ) ? true : false; - en_mc_pmc = (hw->data->all_multicast ==1 ) ? true : false; +if (hw->data->promiscuous) +return hns3_set_promisc_mode (hw, true, true); -return hns3_set_promisc_mode (hw, en_uc_pmc, en_mc_pmc); +return hns3_set_promisc_mode (hw, false, allmulti); } static int
Signature · 1 line
2.23.0
Quoted 7 lines · Wei Hu (Xavier)
This series are updates and fixes for hns3 PMD driver.
Chengchang Tang (3):
net/hns3: remove unnecessary restriction on setting VF's MTU net/hns3: support promiscuous and allmulticast mode for VF net/hns3: fix promiscuous mode for PF
Quoted 6 lines
Hongbo Zheng (1):
net/hns3: support TCP segment offloadWei Hu (Xavier) (1):
net/hns3: fix wrong Tx interrupt when enabling Rx interrupt
Series applied to dpdk-next-net/master, thanks.