Add advanced features for Huawei hinic pmd
Subsystems (2)
cover Add advanced features for Huawei hinic pmd
This patch set adds advanced features for Huawei hinic pmd, such as VLAN filter and VLAN offload, SR-IOV, FW version get, Flow director for LACP, VRRP, BGP and so on.
Xiaoyun Wang (15):
net/hinic/base: add mbox command channel for SRIOV net/hinic/base: add HW interfaces of SRIOV net/hinic: add VF PMD operation interfaces net/hinic: add VLAN filter and offload net/hinic: add allmulticast mode and MTU set net/hinic: add unicast and multicast MAC set net/hinic: add fdir config interface net/hinic: add fdir validate flow operations net/hinic: create and destroy ntuple filter net/hinic: create and destroy fdir filter net/hinic: flush fdir filter
net/hinic: set link down and up
net/hinic: support inner L3 checksum offload net/hinic: support LRO offload
net/hinic: add hinic PMD doc files
doc/guides/nics/features/hinic.ini | 12 +- doc/guides/nics/hinic.rst | 6 + doc/guides/rel_notes/release_19_11.rst | 9 + drivers/net/hinic/Makefile | 2 + drivers/net/hinic/base/hinic_compat.h | 33 - drivers/net/hinic/base/hinic_pmd_cfg.c | 35 + drivers/net/hinic/base/hinic_pmd_cmd.h | 11 + drivers/net/hinic/base/hinic_pmd_hwdev.c | 152 +- drivers/net/hinic/base/hinic_pmd_hwdev.h | 8 + drivers/net/hinic/base/hinic_pmd_hwif.c | 46 +- drivers/net/hinic/base/hinic_pmd_hwif.h | 7 + drivers/net/hinic/base/hinic_pmd_mbox.c | 854 +++++++++++ drivers/net/hinic/base/hinic_pmd_mbox.h | 92 ++ drivers/net/hinic/base/hinic_pmd_mgmt.c | 25 +- drivers/net/hinic/base/hinic_pmd_niccfg.c | 410 ++++- drivers/net/hinic/base/hinic_pmd_niccfg.h | 198 +++ drivers/net/hinic/base/hinic_pmd_nicio.c | 7 + drivers/net/hinic/base/meson.build | 1 + drivers/net/hinic/hinic_pmd_ethdev.c | 920 +++++++++-- drivers/net/hinic/hinic_pmd_ethdev.h | 134 +- drivers/net/hinic/hinic_pmd_flow.c | 2378 +++++++++++++++++++++++++++++ drivers/net/hinic/hinic_pmd_tx.c | 192 ++- drivers/net/hinic/meson.build | 1 + 23 files changed, 5308 insertions(+), 225 deletions(-) create mode 100644 drivers/net/hinic/base/hinic_pmd_mbox.c create mode 100644 drivers/net/hinic/base/hinic_pmd_mbox.h create mode 100644 drivers/net/hinic/hinic_pmd_flow.c
Signature · 1 line
1.8.3.1
PATCH 1/15 net/hinic/base: add mbox command channel for SRIOV
From: Xiaoyun Wang <[email protected]>
Add mbox command channel for SRIOV, which is used to communicate between VF and VF, VF and PF. This patch introduces data structures, initialization, interfaces and commands of mbox channel.
--- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/base/hinic_pmd_mbox.c | 854 ++++++++++++++++++++++++++++++++ drivers/net/hinic/base/hinic_pmd_mbox.h | 92 ++++ drivers/net/hinic/base/meson.build | 1 + 4 files changed, 948 insertions(+) create mode 100644 drivers/net/hinic/base/hinic_pmd_mbox.c create mode 100644 drivers/net/hinic/base/hinic_pmd_mbox.h
drivers/net/hinic/Makefile +1 -0
@@ -59,6 +59,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_mgmt.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_niccfg.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_nicio.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_wq.c +SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_mbox.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_rx.c
drivers/net/hinic/base/hinic_pmd_mbox.c new file +854 -0
854 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_mbox.h new file +92 -0
92 lines not on this page · raw message
drivers/net/hinic/base/meson.build +1 -0
@@ -12,6 +12,7 @@ sources = [ 'hinic_pmd_niccfg.c', 'hinic_pmd_nicio.c', 'hinic_pmd_wq.c', + 'hinic_pmd_mbox.c', ] extra_flags = []
Signature · 1 line
1.8.3.1
PATCH 2/15 net/hinic/base: add HW interfaces of SRIOV
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch makes some HW interfaces support SRIOV,
including: init hwdev, set port state, get default cos, vf dma attribute table, vf txrx flush and so on.
--- drivers/net/hinic/base/hinic_compat.h | 33 ------- drivers/net/hinic/base/hinic_pmd_cfg.c | 35 +++++++ drivers/net/hinic/base/hinic_pmd_cmd.h | 6 ++ drivers/net/hinic/base/hinic_pmd_hwdev.c | 152 +++++++++++++++++++++++++++--- drivers/net/hinic/base/hinic_pmd_hwdev.h | 8 ++ drivers/net/hinic/base/hinic_pmd_hwif.c | 46 ++++++++- drivers/net/hinic/base/hinic_pmd_hwif.h | 7 ++ drivers/net/hinic/base/hinic_pmd_mgmt.c | 25 ++++- drivers/net/hinic/base/hinic_pmd_niccfg.c | 64 ++++++++++++- drivers/net/hinic/base/hinic_pmd_niccfg.h | 18 ++++ drivers/net/hinic/base/hinic_pmd_nicio.c | 7 ++ 11 files changed, 351 insertions(+), 50 deletions(-)
drivers/net/hinic/base/hinic_compat.h +0 -33
@@ -222,39 +222,6 @@ static inline u16 ilog2(u32 n)return res; } - -/** -* hinic_cpu_to_be32 - convert data to big endian 32 bit format -* @data: the data to convert -* @len: length of data to convert, must be Multiple of 4B -**/ -static inline void hinic_cpu_to_be32 (void *data,u32 len) -{ -u32 i; -u32 *mem = (u32 *)data; - -for (i =0 ; i < (len >>2 ); i++) { - *mem =cpu_to_be32 (*mem); - mem++; - } -} - -/** -* hinic_be32_to_cpu - convert data from big endian 32 bit format -* @data: the data to convert -* @len: length of data to convert, must be Multiple of 4B -**/ -static inline void hinic_be32_to_cpu (void *data,u32 len) -{ -u32 i; -u32 *mem = (u32 *)data; - -for (i =0 ; i < (len >>2 ); i++) { - *mem =be32_to_cpu (*mem); - mem++; - } -} -static inline int hinic_mutex_init (pthread_mutex_t *pthreadmutex,const pthread_mutexattr_t *mattr) {
drivers/net/hinic/base/hinic_pmd_cfg.c +35 -0
@@ -8,6 +8,7 @@#include "hinic_pmd_mgmt.h" #include "hinic_pmd_eqs.h" #include "hinic_pmd_cfg.h" +#include "hinic_pmd_mbox.h" bool hinic_support_nic (struct hinic_hwdev *hwdev,struct nic_service_cap *cap) {
@@ -122,6 +123,10 @@ static void hinic_parse_pub_res_cap(struct service_cap *cap, cap->vf_id_start = dev_cap->vf_id_start; cap->max_sqs = dev_cap->nic_max_sq +1 ; cap->max_rqs = dev_cap->nic_max_rq +1 ; + }else { + cap->max_vf =0 ; + cap->max_sqs = dev_cap->nic_max_sq; + cap->max_rqs = dev_cap->nic_max_rq; } cap->chip_svc_type =CFG_SVC_NIC_BIT0 ;
@@ -180,6 +185,28 @@ static int get_cap_from_fw(struct hinic_hwdev *dev, enum func_type type)return 0 ; } +static int get_cap_from_pf (struct hinic_hwdev *dev,enum func_type type) +{ +int err; +u16 in_len, out_len; +struct hinic_dev_cap dev_cap; + +memset (&dev_cap,0 ,sizeof (dev_cap)); + in_len =sizeof (dev_cap); + out_len = in_len; + err =hinic_mbox_to_pf (dev,HINIC_MOD_CFGM ,HINIC_CFG_MBOX_CAP , + &dev_cap, in_len, &dev_cap, &out_len, +CFG_MAX_CMD_TIMEOUT ); +if (err || dev_cap.mgmt_msg_head.status || !out_len) { +PMD_DRV_LOG (ERR ,"Get capability from PF failed, err: %d, status: %d, out_len: %d" , + err, dev_cap.mgmt_msg_head.status, out_len); +return -EFAULT ; + } + +parse_dev_cap (dev, &dev_cap, type); +return 0 ; +} +static int get_dev_cap (struct hinic_hwdev *dev) {int err;
@@ -194,6 +221,14 @@ static int get_dev_cap(struct hinic_hwdev *dev)return err; }break ; +case TYPE_VF : + err =get_cap_from_pf (dev, type); +if (err) { +PMD_DRV_LOG (ERR ,"Get VF capability failed, err: %d" , + err); +return err; + } +break ;default :PMD_DRV_LOG (ERR ,"Unsupported PCI function type" );return -EINVAL ;
drivers/net/hinic/base/hinic_pmd_cmd.h +6 -0
@@ -25,6 +25,12 @@ enum hinic_mod_type {HINIC_MOD_MAX =15 }; +/* only used by VFD communicating with PFD to register or unregister, +* command mode type is HINIC_MOD_L2NIC +*/ +#define HINIC_PORT_CMD_VF_REGISTER 0x0 +#define HINIC_PORT_CMD_VF_UNREGISTER 0x1 +/* cmd of mgmt CPU message for NIC module */ enum hinic_port_cmd {HINIC_PORT_CMD_MGMT_RESET =0x0 ,
drivers/net/hinic/base/hinic_pmd_hwdev.c +141 -11
194 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_hwdev.h +8 -0
@@ -14,6 +14,8 @@#define MAX_PCIE_DFX_BUF_SIZE 1024 +#define HINIC_DEV_BUSY_ACTIVE_FW 0xFE +/* dma pool */ struct dma_pool {u32 inuse;
@@ -436,6 +438,7 @@ struct hinic_hwdev {struct hinic_hwif *hwif;struct cfg_mgmt_info *cfg_mgmt;struct hinic_aeqs *aeqs; +struct hinic_mbox_func_to_func *func_to_func;struct hinic_msg_pf_to_mgmt *pf_to_mgmt;struct hinic_cmdqs *cmdqs;struct hinic_nic_io *nic_io;
@@ -482,4 +485,9 @@ void hinic_hilink_async_event_handle(struct hinic_hwdev *hwdev, u8 cmd,int hinic_set_pagesize (void *hwdev,u8 page_size); +void hinic_cpu_to_be32 (void *data,u32 len); + +void hinic_be32_to_cpu (void *data,u32 len); + +#endif /* _HINIC_PMD_HWDEV_H_ */
drivers/net/hinic/base/hinic_pmd_hwif.c +44 -2
88 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_hwif.h +7 -0
@@ -104,6 +104,9 @@ static inline u32 hinic_hwif_read_reg(struct hinic_hwif *hwif, u32 reg)void hinic_free_db_addr (void *hwdev,void __iomem *db_base); +int wait_until_doorbell_flush_states (struct hinic_hwif *hwif, +enum hinic_doorbell_ctrl states); +void hinic_set_msix_state (void *hwdev,u16 msix_idx,enum hinic_msix_state flag);
@@ -116,4 +119,8 @@ void hinic_misx_intr_clear_resend_bit(void *hwdev, u16 msix_idx,void hinic_hwif_res_free (struct hinic_hwdev *hwdev); +u8 hinic_pf_id_of_vf (void *hwdev); + +u8 hinic_dma_attr_entry_num (void *hwdev); +#endif /* _HINIC_PMD_HWIF_H_ */
drivers/net/hinic/base/hinic_pmd_mgmt.c +22 -3
@@ -7,6 +7,7 @@#include "hinic_pmd_hwdev.h" #include "hinic_pmd_hwif.h" #include "hinic_pmd_mgmt.h" +#include "hinic_pmd_mbox.h" #define BUF_OUT_DEFAULT_SIZE 1
@@ -464,6 +465,9 @@ static int hinic_get_mgmt_channel_status(void *hwdev)struct hinic_hwif *hwif = ((struct hinic_hwdev *)hwdev)->hwif;u32 val; +if (hinic_func_type ((struct hinic_hwdev *)hwdev) ==TYPE_VF ) +return false; + val =hinic_hwif_read_reg (hwif,HINIC_ICPL_RESERVD_ADDR );return HINIC_GET_MGMT_CHANNEL_STATUS (val,MGMT_CHANNEL_STATUS );
@@ -482,9 +486,13 @@ int hinic_msg_to_mgmt_sync(void *hwdev, enum hinic_mod_type mod, u8 cmd,if (hinic_get_mgmt_channel_status (hwdev))return -EPERM ; - rc =hinic_pf_to_mgmt_sync (hwdev, mod, cmd, buf_in, - in_size, buf_out, out_size, - timeout); +if (hinic_func_type (hwdev) ==TYPE_VF ) { + rc =hinic_mbox_to_pf (hwdev, mod, cmd, buf_in, in_size, + buf_out, out_size, timeout); + }else { + rc =hinic_pf_to_mgmt_sync (hwdev, mod, cmd, buf_in, in_size, + buf_out, out_size, timeout); + }return rc; }
@@ -667,6 +675,9 @@ static int hinic_handle_aeqe(void *handle, enum hinic_aeq_type event,case HINIC_MSG_FROM_MGMT_CPU : rc =hinic_mgmt_msg_aeqe_handler (handle, data, size, param);break ; +case HINIC_MBX_FROM_FUNC : + rc =hinic_mbox_func_aeqe_handler (handle, data, size, param); +break ;default :PMD_DRV_LOG (ERR ,"Unknown event type: 0x%x, size: %d" , event, size);
@@ -753,6 +764,10 @@ int hinic_comm_pf_to_mgmt_init(struct hinic_hwdev *hwdev) {int rc; +/* VF do not support send msg to mgmt directly */ +if (hinic_func_type (hwdev) ==TYPE_VF ) +return 0 ; + rc =hinic_pf_to_mgmt_init (hwdev);if (rc)return rc;
@@ -764,6 +779,10 @@ int hinic_comm_pf_to_mgmt_init(struct hinic_hwdev *hwdev)void hinic_comm_pf_to_mgmt_free (struct hinic_hwdev *hwdev) { +/* VF do not support send msg to mgmt directly */ +if (hinic_func_type (hwdev) ==TYPE_VF ) +return ; +hinic_pf_to_mgmt_free (hwdev); }
drivers/net/hinic/base/hinic_pmd_niccfg.c +63 -1
97 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_niccfg.h +18 -0
@@ -562,6 +562,18 @@ struct hinic_clear_qp_resource {u16 rsvd1; }; +struct hinic_dcb_state { +u8 dcb_on; +u8 default_cos; +u8 up_cos[8 ]; +}; + +struct hinic_vf_default_cos { +struct hinic_mgmt_msg_head mgmt_msg_head; + +struct hinic_dcb_state state; +}; +/* set physical port Anti-Attack rate */ struct hinic_port_anti_attack_rate {struct hinic_mgmt_msg_head mgmt_msg_head;
@@ -655,4 +667,10 @@ int hinic_set_link_status_follow(void *hwdev,void hinic_clear_phy_port_stats (struct hinic_hwdev *hwdev); +int hinic_vf_func_init (struct hinic_hwdev *hwdev); + +void hinic_vf_func_free (struct hinic_hwdev *hwdev); + +int hinic_vf_get_default_cos (struct hinic_hwdev *hwdev,u8 *cos_id); +#endif /* _HINIC_PMD_NICCFG_H_ */
drivers/net/hinic/base/hinic_pmd_nicio.c +7 -0
@@ -618,6 +618,12 @@ static int hinic_init_nic_hwdev(struct hinic_hwdev *hwdev) goto err_init_nic_hwdev; } + err =hinic_vf_func_init (hwdev); +if (err) { +PMD_DRV_LOG (ERR ,"Failed to init nic mbox" ); + goto err_init_nic_hwdev; + } + err =hinic_set_fast_recycle_mode (hwdev,RECYCLE_MODE_DPDK );if (err) {PMD_DRV_LOG (ERR ,"Failed to set fast recycle mode" );
@@ -632,6 +638,7 @@ static int hinic_init_nic_hwdev(struct hinic_hwdev *hwdev)static void hinic_free_nic_hwdev (struct hinic_hwdev *hwdev) { +hinic_vf_func_free (hwdev); hwdev->nic_io =NULL ; }
Signature · 1 line
1.8.3.1
PATCH 3/15 net/hinic: add VF PMD operation interfaces
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch adds VF PMD operation interfaces to support SRIOV.
--- drivers/net/hinic/hinic_pmd_ethdev.c | 236 +++++++++++++++++++++++------------ 1 file changed, 159 insertions(+), 77 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.c +159 -77
@@ -20,6 +20,7 @@#include "base/hinic_pmd_cmdq.h" #include "base/hinic_pmd_niccfg.h" #include "base/hinic_pmd_nicio.h" +#include "base/hinic_pmd_mbox.h" #include "hinic_pmd_ethdev.h" #include "hinic_pmd_tx.h" #include "hinic_pmd_rx.h"
@@ -32,6 +33,8 @@#define HINIC_DEV_ID_MEZZ_25GE 0x0210#define HINIC_DEV_ID_MEZZ_40GE 0x020D#define HINIC_DEV_ID_MEZZ_100GE 0x0205 +#define HINIC_DEV_ID_VF 0x375E +#define HINIC_DEV_ID_VF_HV 0x379E#define HINIC_SERVICE_MODE_NIC 2
@@ -197,10 +200,16 @@ struct hinic_xstats_name_off {static int hinic_xstats_calc_num (struct hinic_nic_dev *nic_dev) { -return (HINIC_VPORT_XSTATS_NUM + -HINIC_PHYPORT_XSTATS_NUM + -HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq + -HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq); +if (HINIC_IS_VF (nic_dev->hwdev)) { +return (HINIC_VPORT_XSTATS_NUM + +HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq + +HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq); + }else { +return (HINIC_VPORT_XSTATS_NUM + +HINIC_PHYPORT_XSTATS_NUM + +HINIC_RXQ_XSTATS_NUM * nic_dev->num_rq + +HINIC_TXQ_XSTATS_NUM * nic_dev->num_sq); + } }static const struct rte_eth_desc_lim hinic_rx_desc_lim = {
@@ -913,6 +922,8 @@ static int hinic_dev_start(struct rte_eth_dev *dev) (void )hinic_set_vport_enable (nic_dev->hwdev, false); en_vport_fail: +hinic_set_pf_status (nic_dev->hwdev->hwif,HINIC_PF_STATUS_INIT ); +/* Flush tx && rx chip resources in case of set vport fake fail */ (void )hinic_flush_qp_res (nic_dev->hwdev);rte_delay_ms (100 );
@@ -1670,6 +1681,9 @@ static int hinic_dev_xstats_get(struct rte_eth_dev *dev, count++; } +if (HINIC_IS_VF (nic_dev->hwdev)) +return count; +/* Get stats from hinic_phy_port_stats */ err =hinic_get_phy_port_stats (nic_dev->hwdev, &port_stats);if (err)
@@ -1738,6 +1752,9 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev *dev, count++; } +if (HINIC_IS_VF (nic_dev->hwdev)) +return count; +/* get phy port stats */ for (i =0 ; i <HINIC_PHYPORT_XSTATS_NUM ; i++) { snprintf(xstats_names[count].name,
@@ -1778,18 +1795,39 @@ static int hinic_set_default_dcb_feature(struct hinic_nic_dev *nic_dev) up_pgid, up_bw, up_strict); } -static void hinic_init_default_cos (struct hinic_nic_dev *nic_dev) +static int hinic_init_default_cos (struct hinic_nic_dev *nic_dev) { - nic_dev->default_cos = - (hinic_global_func_id (nic_dev->hwdev) + -DEFAULT_BASE_COS ) %NR_MAX_COS ; +u8 cos_id =0 ; +int err; + +if (!HINIC_IS_VF (nic_dev->hwdev)) { + nic_dev->default_cos = + (hinic_global_func_id (nic_dev->hwdev) + +DEFAULT_BASE_COS ) %NR_MAX_COS ; + }else { + err =hinic_vf_get_default_cos (nic_dev->hwdev, &cos_id); +if (err) { +PMD_DRV_LOG (ERR ,"Get VF default cos failed, err: %d" , + err); +return HINIC_ERROR ; + } + + nic_dev->default_cos = cos_id; + } + +return 0 ; }static int hinic_set_default_hw_feature (struct hinic_nic_dev *nic_dev) {int err; -hinic_init_default_cos (nic_dev); + err =hinic_init_default_cos (nic_dev); +if (err) +return err; + +if (hinic_func_type (nic_dev->hwdev) ==TYPE_VF ) +return 0 ;/* Restore DCB configure to default status */ err =hinic_set_default_dcb_feature (nic_dev);
@@ -1825,6 +1863,9 @@ static int32_t hinic_card_workmode_check(struct hinic_nic_dev *nic_dev)struct hinic_board_info info = {0 };int rc; +if (hinic_func_type (nic_dev->hwdev) ==TYPE_VF ) +return 0 ; + rc =hinic_get_board_info (nic_dev->hwdev, &info);if (rc)return rc;
@@ -1840,7 +1881,7 @@ static int hinic_copy_mempool_init(struct hinic_nic_dev *nic_dev) nic_dev->cpy_mpool =rte_pktmbuf_pool_create (nic_dev->proc_dev_name,HINIC_COPY_MEMPOOL_DEPTH , -RTE_CACHE_LINE_SIZE ,0 , +0 ,0 ,HINIC_COPY_MBUF_SIZE ,rte_socket_id ());if (!nic_dev->cpy_mpool) {
@@ -1951,6 +1992,14 @@ static int hinic_nic_dev_create(struct rte_eth_dev *eth_dev) goto init_pf_to_mgmt_fail; } +/* init mailbox */ + rc =hinic_comm_func_to_func_init (nic_dev->hwdev); +if (rc) { +PMD_DRV_LOG (ERR ,"Initialize func_to_func failed, dev_name: %s" , + eth_dev->data->name); + goto init_func_to_func_fail; + } + rc =hinic_card_workmode_check (nic_dev);if (rc) { PMD_DRV_LOG(ERR, "Check card workmode failed, dev_name: %s",
@@ -2050,6 +2099,9 @@ static int hinic_nic_dev_create(struct rte_eth_dev *eth_dev) init_cmdq_fail: l2nic_reset_fail: workmode_check_fail: +hinic_comm_func_to_func_free (nic_dev->hwdev); + +init_func_to_func_fail:hinic_comm_pf_to_mgmt_free (nic_dev->hwdev); init_pf_to_mgmt_fail:
@@ -2083,6 +2135,7 @@ static void hinic_nic_dev_destroy(struct rte_eth_dev *eth_dev)hinic_deinit_nicio (nic_dev->hwdev);hinic_deactivate_hwdev_state (nic_dev->hwdev);hinic_comm_cmdqs_free (nic_dev->hwdev); +hinic_comm_func_to_func_free (nic_dev->hwdev);hinic_comm_pf_to_mgmt_free (nic_dev->hwdev);hinic_comm_aeqs_free (nic_dev->hwdev);free_cfg_mgmt (nic_dev->hwdev);
@@ -2092,6 +2145,93 @@ static void hinic_nic_dev_destroy(struct rte_eth_dev *eth_dev) nic_dev->hwdev =NULL ; } +/** +* DPDK callback to close the device. +* +* @param dev +* Pointer to Ethernet device structure. +*/ +static void hinic_dev_close (struct rte_eth_dev *dev) +{ +struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); + +if (hinic_test_and_set_bit (HINIC_DEV_CLOSE , &nic_dev->dev_status)) { +PMD_DRV_LOG (WARNING ,"Device %s already closed" , + dev->data->name); +return ; + } + +/* stop device first */ +hinic_dev_stop (dev); + +/* rx_cqe, rx_info */ +hinic_free_all_rx_resources (dev); + +/* tx_info */ +hinic_free_all_tx_resources (dev); + +/* free wq, pi_dma_addr */ +hinic_free_all_rq (nic_dev); + +/* free wq, db_addr */ +hinic_free_all_sq (nic_dev); + +/* deinit mac vlan tbl */ +hinic_deinit_mac_addr (dev); + +/* disable hardware and uio interrupt */ +hinic_disable_interrupt (dev); + +/* deinit nic hardware device */ +hinic_nic_dev_destroy (dev); +} + +static const struct eth_dev_ops hinic_pmd_ops = { + .dev_configure = hinic_dev_configure, + .dev_infos_get = hinic_dev_infos_get, + .rx_queue_setup = hinic_rx_queue_setup, + .tx_queue_setup = hinic_tx_queue_setup, + .dev_start = hinic_dev_start, + .link_update = hinic_link_update, + .rx_queue_release = hinic_rx_queue_release, + .tx_queue_release = hinic_tx_queue_release, + .dev_stop = hinic_dev_stop, + .dev_close = hinic_dev_close, + .promiscuous_enable = hinic_dev_promiscuous_enable, + .promiscuous_disable = hinic_dev_promiscuous_disable, + .rss_hash_update = hinic_rss_hash_update, + .rss_hash_conf_get = hinic_rss_conf_get, + .reta_update = hinic_rss_indirtbl_update, + .reta_query = hinic_rss_indirtbl_query, + .stats_get = hinic_dev_stats_get, + .stats_reset = hinic_dev_stats_reset, + .xstats_get = hinic_dev_xstats_get, + .xstats_reset = hinic_dev_xstats_reset, + .xstats_get_names = hinic_dev_xstats_get_names, +}; + +static const struct eth_dev_ops hinic_pmd_vf_ops = { + .dev_configure = hinic_dev_configure, + .dev_infos_get = hinic_dev_infos_get, + .rx_queue_setup = hinic_rx_queue_setup, + .tx_queue_setup = hinic_tx_queue_setup, + .dev_start = hinic_dev_start, + .link_update = hinic_link_update, + .rx_queue_release = hinic_rx_queue_release, + .tx_queue_release = hinic_tx_queue_release, + .dev_stop = hinic_dev_stop, + .dev_close = hinic_dev_close, + .rss_hash_update = hinic_rss_hash_update, + .rss_hash_conf_get = hinic_rss_conf_get, + .reta_update = hinic_rss_indirtbl_update, + .reta_query = hinic_rss_indirtbl_query, + .stats_get = hinic_dev_stats_get, + .stats_reset = hinic_dev_stats_reset, + .xstats_get = hinic_dev_xstats_get, + .xstats_reset = hinic_dev_xstats_reset, + .xstats_get_names = hinic_dev_xstats_get_names, +}; +static int hinic_func_init (struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;
@@ -2146,6 +2286,11 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) goto create_nic_dev_fail; } +if (HINIC_IS_VF (nic_dev->hwdev)) + eth_dev->dev_ops = &hinic_pmd_vf_ops; +else + eth_dev->dev_ops = &hinic_pmd_ops; + rc =hinic_init_mac_addr (eth_dev);if (rc) { PMD_DRV_LOG(ERR, "Initialize mac table failed, dev_name: %s",
@@ -2187,6 +2332,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)hinic_deinit_mac_addr (eth_dev); init_mac_fail: + eth_dev->dev_ops =NULL ;hinic_nic_dev_destroy (eth_dev); create_nic_dev_fail:
@@ -2199,71 +2345,6 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)return rc; } -/** -* DPDK callback to close the device. -* -* @param dev -* Pointer to Ethernet device structure. -*/ -static void hinic_dev_close (struct rte_eth_dev *dev) -{ -struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); - -if (hinic_test_and_set_bit (HINIC_DEV_CLOSE , &nic_dev->dev_status)) { -PMD_DRV_LOG (WARNING ,"Device %s already closed" , - dev->data->name); -return ; - } - -/* stop device first */ -hinic_dev_stop (dev); - -/* rx_cqe, rx_info */ -hinic_free_all_rx_resources (dev); - -/* tx_info */ -hinic_free_all_tx_resources (dev); - -/* free wq, pi_dma_addr */ -hinic_free_all_rq (nic_dev); - -/* free wq, db_addr */ -hinic_free_all_sq (nic_dev); - -/* deinit mac vlan tbl */ -hinic_deinit_mac_addr (dev); - -/* disable hardware and uio interrupt */ -hinic_disable_interrupt (dev); - -/* deinit nic hardware device */ -hinic_nic_dev_destroy (dev); -} - -static const struct eth_dev_ops hinic_pmd_ops = { - .dev_configure = hinic_dev_configure, - .dev_infos_get = hinic_dev_infos_get, - .rx_queue_setup = hinic_rx_queue_setup, - .tx_queue_setup = hinic_tx_queue_setup, - .dev_start = hinic_dev_start, - .link_update = hinic_link_update, - .rx_queue_release = hinic_rx_queue_release, - .tx_queue_release = hinic_tx_queue_release, - .dev_stop = hinic_dev_stop, - .dev_close = hinic_dev_close, - .promiscuous_enable = hinic_dev_promiscuous_enable, - .promiscuous_disable = hinic_dev_promiscuous_disable, - .rss_hash_update = hinic_rss_hash_update, - .rss_hash_conf_get = hinic_rss_conf_get, - .reta_update = hinic_rss_indirtbl_update, - .reta_query = hinic_rss_indirtbl_query, - .stats_get = hinic_dev_stats_get, - .stats_reset = hinic_dev_stats_reset, - .xstats_get = hinic_dev_xstats_get, - .xstats_reset = hinic_dev_xstats_reset, - .xstats_get_names = hinic_dev_xstats_get_names, -}; -static int hinic_dev_init (struct rte_eth_dev *eth_dev) {struct rte_pci_device *pci_dev;
@@ -2276,8 +2357,7 @@ static int hinic_dev_init(struct rte_eth_dev *eth_dev) (rte_eal_process_type () ==RTE_PROC_PRIMARY ) ? "primary" : "secondary"); -/* rte_eth_dev ops, rx_burst and tx_burst */ - eth_dev->dev_ops = &hinic_pmd_ops; +/* rte_eth_dev rx_burst and tx_burst */ eth_dev->rx_pkt_burst = hinic_recv_pkts; eth_dev->tx_pkt_burst = hinic_xmit_pkts;
@@ -2311,6 +2391,8 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev) { RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_25GE) }, { RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_40GE) }, { RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_MEZZ_100GE) }, + { RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_VF) }, + { RTE_PCI_DEVICE(HINIC_HUAWEI_VENDOR_ID, HINIC_DEV_ID_VF_HV) }, {.vendor_id = 0}, };
Signature · 1 line
1.8.3.1
PATCH 4/15 net/hinic: add VLAN filter and offload
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch adds VLAN filter and VLAN offload.
--- drivers/net/hinic/base/hinic_pmd_cmd.h | 1 + drivers/net/hinic/base/hinic_pmd_niccfg.c | 119 ++++++++++++++++++ drivers/net/hinic/base/hinic_pmd_niccfg.h | 31 +++++ drivers/net/hinic/hinic_pmd_ethdev.c | 196 +++++++++++++++++++++++++++++- drivers/net/hinic/hinic_pmd_ethdev.h | 7 +- 5 files changed, 352 insertions(+), 2 deletions(-)
drivers/net/hinic/base/hinic_pmd_cmd.h +1 -0
@@ -140,6 +140,7 @@ enum hinic_port_cmd {HINIC_PORT_CMD_SET_VHD_CFG =0xF7 ,HINIC_PORT_CMD_SET_LINK_FOLLOW =0xF8 , + HINIC_PORT_CMD_SET_VLAN_FILTER = 0xFF };/* cmd of mgmt CPU message for HW module */
drivers/net/hinic/base/hinic_pmd_niccfg.c +119 -0
125 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_niccfg.h +31 -0
@@ -380,6 +380,29 @@ struct hinic_mtu {u32 mtu; }; +struct hinic_vlan_config { +struct hinic_mgmt_msg_head mgmt_msg_head; + +u16 func_id; +u16 vlan_id; +}; + +struct hinic_vlan_filter { +struct hinic_mgmt_msg_head mgmt_msg_head; + +u16 func_id; +u8 rsvd1[2 ]; +u32 vlan_filter_ctrl; +}; + +struct hinic_vlan_offload { +struct hinic_mgmt_msg_head mgmt_msg_head; + +u16 func_id; +u8 vlan_rx_offload; +u8 rsvd1[5 ]; +}; +struct hinic_get_link {struct hinic_mgmt_msg_head mgmt_msg_head;
@@ -597,6 +620,14 @@ int hinic_update_mac(void *hwdev, u8 *old_mac, u8 *new_mac, u16 vlan_id,int hinic_set_port_mtu (void *hwdev,u32 new_mtu); +int hinic_add_vlan (void *hwdev,u16 vlan_id,u16 func_id); + +int hinic_del_vlan (void *hwdev,u16 vlan_id,u16 func_id); + +int hinic_config_vlan_filter (void *hwdev,u32 vlan_filter_ctrl); + +int hinic_set_rx_vlan_offload (void *hwdev,u8 en); +int hinic_set_vport_enable (void *hwdev,bool enable);int hinic_set_port_enable (void *hwdev,bool enable);
drivers/net/hinic/hinic_pmd_ethdev.c +195 -1
250 lines not on this page · raw message
drivers/net/hinic/hinic_pmd_ethdev.h +6 -1
@@ -31,6 +31,9 @@#define HINIC_TXD_ALIGN 1#define HINIC_RXD_ALIGN 1 +#define HINIC_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t)) +#define HINIC_VFTA_SIZE (4096 / HINIC_UINT32_BIT_SIZE) +enum hinic_dev_status {HINIC_DEV_INIT ,HINIC_DEV_CLOSE ,
@@ -54,10 +57,12 @@ struct hinic_nic_dev {u8 num_rss;u8 rx_queue_list[HINIC_MAX_RX_QUEUES ]; +u32 vfta[HINIC_VFTA_SIZE ];/* VLAN bitmap */ +/* info */ unsigned int flags;struct nic_service_cap nic_cap; -u32 rx_mode_status;/* promisc allmulticast */ +u32 rx_mode_status;/* promisc or allmulticast */ unsigned long dev_status;/* dpdk only */
Signature · 1 line
1.8.3.1
PATCH 5/15 net/hinic: add allmulticast mode and MTU set
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
When enable allmulticast mode, all multicast packets can be received. Add mtu set, the range of MTU is from 256 to 9600.
--- drivers/net/hinic/hinic_pmd_ethdev.c | 99 +++++++++++++++++++++++++++++++++++- drivers/net/hinic/hinic_pmd_ethdev.h | 3 -- 2 files changed, 98 insertions(+), 4 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.c +98 -1
@@ -58,6 +58,12 @@#define HINIC_VLAN_FILTER_EN (1U << 0) +#define HINIC_MTU_TO_PKTLEN (mtu) \ + ((mtu) + ETH_HLEN + ETH_CRC_LEN) + +#define HINIC_PKTLEN_TO_MTU (pktlen) \ + ((pktlen) - (ETH_HLEN + ETH_CRC_LEN)) +/** Driver-specific log messages type. */ int hinic_logtype;
@@ -711,7 +717,9 @@ static void hinic_get_speed_capa(struct rte_eth_dev *dev, uint32_t *speed_capa)DEV_RX_OFFLOAD_IPV4_CKSUM |DEV_RX_OFFLOAD_UDP_CKSUM |DEV_RX_OFFLOAD_TCP_CKSUM | -DEV_RX_OFFLOAD_VLAN_FILTER ; +DEV_RX_OFFLOAD_VLAN_FILTER | +DEV_RX_OFFLOAD_SCATTER | +DEV_RX_OFFLOAD_JUMBO_FRAME ; info->tx_queue_offload_capa =0 ; info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
@@ -1351,6 +1359,33 @@ static void hinic_deinit_mac_addr(struct rte_eth_dev *eth_dev) eth_dev->data->name); } +static int hinic_dev_set_mtu (struct rte_eth_dev *dev,uint16_t mtu) +{ +int ret =0 ; +struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); + +PMD_DRV_LOG (INFO ,"Set port mtu, port_id: %d, mtu: %d, max_pkt_len: %d" , + dev->data->port_id, mtu,HINIC_MTU_TO_PKTLEN (mtu)); + +if (mtu <HINIC_MIN_MTU_SIZE || mtu >HINIC_MAX_MTU_SIZE ) { +PMD_DRV_LOG (ERR ,"Invalid mtu: %d, must between %d and %d" , + mtu,HINIC_MIN_MTU_SIZE ,HINIC_MAX_MTU_SIZE ); +return -EINVAL ; + } + + ret =hinic_set_port_mtu (nic_dev->hwdev, mtu); +if (ret) { +PMD_DRV_LOG (ERR ,"Set port mtu failed, ret: %d" , ret); +return ret; + } + +/* update max frame size */ + dev->data->dev_conf.rxmode.max_rx_pkt_len =HINIC_MTU_TO_PKTLEN (mtu); + nic_dev->mtu_size = mtu; + +return ret; +} +static void hinic_store_vlan_filter (struct hinic_nic_dev *nic_dev,u16 vlan_id,bool on) {
@@ -1518,6 +1553,62 @@ static void hinic_remove_all_vlanid(struct rte_eth_dev *eth_dev)hinic_store_vlan_filter (nic_dev, i, false); } } + +static int hinic_set_dev_allmulticast (struct hinic_nic_dev *nic_dev, +bool enable) +{ +u32 rx_mode_ctrl = nic_dev->rx_mode_status; + +if (enable) + rx_mode_ctrl |=HINIC_RX_MODE_MC_ALL ; +else + rx_mode_ctrl &= (~HINIC_RX_MODE_MC_ALL ); + +return hinic_config_rx_mode (nic_dev, rx_mode_ctrl); +} + +/** +* DPDK callback to enable allmulticast mode. +* +* @param dev +* Pointer to Ethernet device structure. +*/ +static void hinic_dev_allmulticast_enable (struct rte_eth_dev *dev) +{ +int ret =HINIC_OK ; +struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); + + ret =hinic_set_dev_allmulticast (nic_dev, true); +if (ret) { +PMD_DRV_LOG (ERR ,"Enable allmulticast failed, error: %d" , ret); +return ; + } + +PMD_DRV_LOG (INFO ,"Enable allmulticast succed, nic_dev: %s, port_id: %d" , + nic_dev->proc_dev_name, dev->data->port_id); +} + +/** +* DPDK callback to disable allmulticast mode. +* +* @param dev +* Pointer to Ethernet device structure. +*/ +static void hinic_dev_allmulticast_disable (struct rte_eth_dev *dev) +{ +int ret =HINIC_OK ; +struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); + + ret =hinic_set_dev_allmulticast (nic_dev, false); +if (ret) { +PMD_DRV_LOG (ERR ,"Disable allmulticast failed, error: %d" , ret); +return ; + } + +PMD_DRV_LOG (INFO ,"Disable allmulticast succed, nic_dev: %s, port_id: %d" , + nic_dev->proc_dev_name, dev->data->port_id); +} +/** * DPDK callback to enable promiscuous mode. *
@@ -2387,8 +2478,11 @@ static void hinic_dev_close(struct rte_eth_dev *dev) .tx_queue_release = hinic_tx_queue_release, .dev_stop = hinic_dev_stop, .dev_close = hinic_dev_close, + .mtu_set = hinic_dev_set_mtu, .vlan_filter_set = hinic_vlan_filter_set, .vlan_offload_set = hinic_vlan_offload_set, + .allmulticast_enable = hinic_dev_allmulticast_enable, + .allmulticast_disable = hinic_dev_allmulticast_disable, .promiscuous_enable = hinic_dev_promiscuous_enable, .promiscuous_disable = hinic_dev_promiscuous_disable, .rss_hash_update = hinic_rss_hash_update,
@@ -2413,8 +2507,11 @@ static void hinic_dev_close(struct rte_eth_dev *dev) .tx_queue_release = hinic_tx_queue_release, .dev_stop = hinic_dev_stop, .dev_close = hinic_dev_close, + .mtu_set = hinic_dev_set_mtu, .vlan_filter_set = hinic_vlan_filter_set, .vlan_offload_set = hinic_vlan_offload_set, + .allmulticast_enable = hinic_dev_allmulticast_enable, + .allmulticast_disable = hinic_dev_allmulticast_disable, .rss_hash_update = hinic_rss_hash_update, .rss_hash_conf_get = hinic_rss_conf_get, .reta_update = hinic_rss_indirtbl_update,
drivers/net/hinic/hinic_pmd_ethdev.h +0 -3
@@ -20,9 +20,6 @@#define SIZE_8BYTES (size) (ALIGN((u32)(size), 8) >> 3) -#define HINIC_PKTLEN_TO_MTU (pktlen) \ - ((pktlen) - (ETH_HLEN + ETH_CRC_LEN)) -#define HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev) \ ((struct hinic_nic_dev *)(dev)->data->dev_private)
Signature · 1 line
1.8.3.1
PATCH 6/15 net/hinic: add unicast and multicast MAC set
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch adds unicast and multicast set interfaces. Application can add or remove unicast MAC address, also can set multicast MAC address, tha maximum multicast list size is 2048.
--- drivers/net/hinic/base/hinic_pmd_niccfg.c | 37 +++++ drivers/net/hinic/hinic_pmd_ethdev.c | 245 ++++++++++++++++++++++++++++-- drivers/net/hinic/hinic_pmd_ethdev.h | 2 + 3 files changed, 270 insertions(+), 14 deletions(-)
drivers/net/hinic/base/hinic_pmd_niccfg.c +37 -0
@@ -209,6 +209,43 @@ int hinic_get_default_mac(void *hwdev, u8 *mac_addr)return 0 ; } +int hinic_update_mac (void *hwdev,u8 *old_mac,u8 *new_mac,u16 vlan_id, +u16 func_id) +{ +struct hinic_port_mac_update mac_info; +u16 out_size =sizeof (mac_info); +int err; + +if (!hwdev || !old_mac || !new_mac) { +PMD_DRV_LOG (ERR ,"Hwdev, old_mac or new_mac is NULL\n" ); +return -EINVAL ; + } + +memset (&mac_info,0 ,sizeof (mac_info)); + mac_info.mgmt_msg_head.resp_aeq_num =HINIC_AEQ1 ; + mac_info.func_id = func_id; + mac_info.vlan_id = vlan_id; +memcpy (mac_info.old_mac, old_mac,ETH_ALEN ); +memcpy (mac_info.new_mac, new_mac,ETH_ALEN ); + + err =l2nic_msg_to_mgmt_sync (hwdev,HINIC_PORT_CMD_UPDATE_MAC , + &mac_info,sizeof (mac_info), + &mac_info, &out_size); +if (err || !out_size || + (mac_info.mgmt_msg_head.status && + mac_info.mgmt_msg_head.status !=HINIC_PF_SET_VF_ALREADY )) { +PMD_DRV_LOG (ERR ,"Failed to update MAC, err: %d, status: 0x%x, out size: 0x%x\n" , + err, mac_info.mgmt_msg_head.status, out_size); +return -EINVAL ; + } +if (mac_info.mgmt_msg_head.status ==HINIC_PF_SET_VF_ALREADY ) { +PMD_DRV_LOG (WARNING ,"PF has already set vf mac, Ignore update operation.\n" ); +return HINIC_PF_SET_VF_ALREADY ; + } + +return 0 ; +} +int hinic_set_port_mtu (void *hwdev,u32 new_mtu) {struct hinic_mtu mtu_info;
drivers/net/hinic/hinic_pmd_ethdev.c +231 -14
323 lines not on this page · raw message
drivers/net/hinic/hinic_pmd_ethdev.h +2 -0
@@ -56,6 +56,8 @@ struct hinic_nic_dev {u32 vfta[HINIC_VFTA_SIZE ];/* VLAN bitmap */ +struct rte_ether_addr default_addr; +struct rte_ether_addr *mc_list;/* info */ unsigned int flags;struct nic_service_cap nic_cap;
Signature · 1 line
1.8.3.1
PATCH 7/15 net/hinic: add fdir config interface
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
Add fdir config operation, including set fdir filter, normal filter, set and clear fdir tcam.
--- drivers/net/hinic/base/hinic_pmd_cmd.h | 2 + drivers/net/hinic/base/hinic_pmd_niccfg.c | 157 ++++++++++++++++++++++++++++++ drivers/net/hinic/base/hinic_pmd_niccfg.h | 136 ++++++++++++++++++++++++++ 3 files changed, 295 insertions(+)
drivers/net/hinic/base/hinic_pmd_cmd.h +2 -0
@@ -140,6 +140,8 @@ enum hinic_port_cmd {HINIC_PORT_CMD_SET_VHD_CFG =0xF7 ,HINIC_PORT_CMD_SET_LINK_FOLLOW =0xF8 , +HINIC_PORT_CMD_Q_FILTER =0xFC , +HINIC_PORT_CMD_TCAM_FILTER =0xFE , HINIC_PORT_CMD_SET_VLAN_FILTER = 0xFF };
drivers/net/hinic/base/hinic_pmd_niccfg.c +157 -0
166 lines not on this page · raw message
drivers/net/hinic/base/hinic_pmd_niccfg.h +136 -0
146 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 8/15 net/hinic: add fdir validate flow operations
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch is to validate the filter rules, which includes ntuple filter, ethertype filter and fdir filter. The packets type that supported are BGP,VRRP,LACP,ARP and ICMP.
--- drivers/net/hinic/Makefile | 1 + drivers/net/hinic/hinic_pmd_ethdev.c | 41 ++ drivers/net/hinic/hinic_pmd_ethdev.h | 32 +- drivers/net/hinic/hinic_pmd_flow.c | 1178 ++++++++++++++++++++++++++++++++++ drivers/net/hinic/meson.build | 1 + 5 files changed, 1249 insertions(+), 4 deletions(-) create mode 100644 drivers/net/hinic/hinic_pmd_flow.c
drivers/net/hinic/Makefile +1 -0
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_niccfg.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_nicio.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_wq.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_mbox.c +SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_flow.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_HINIC_PMD) += hinic_pmd_rx.c
drivers/net/hinic/hinic_pmd_ethdev.c +41 -0
53 lines not on this page · raw message
drivers/net/hinic/hinic_pmd_ethdev.h +28 -4
@@ -11,12 +11,12 @@#include "base/hinic_compat.h" #include "base/hinic_pmd_cfg.h" -#define HINIC_DEV_NAME_LEN (32) -#define HINIC_MAX_RX_QUEUES (64) +#define HINIC_DEV_NAME_LEN 32 +#define HINIC_MAX_RX_QUEUES 64/* mbuf pool for copy invalid mbuf segs */ -#define HINIC_COPY_MEMPOOL_DEPTH (128) -#define HINIC_COPY_MBUF_SIZE (4096) +#define HINIC_COPY_MEMPOOL_DEPTH 128 +#define HINIC_COPY_MBUF_SIZE 4096#define SIZE_8BYTES (size) (ALIGN((u32)(size), 8) >> 3)
@@ -38,6 +38,30 @@ enum hinic_dev_status { HINIC_DEV_INTR_EN, }; +/* Information about the fdir mode. */ +struct hinic_hw_fdir_mask { +uint32_t src_ipv4_mask; +uint32_t dst_ipv4_mask; +uint16_t src_port_mask; +uint16_t dst_port_mask; +}; + +/* Flow Director attribute */ +struct hinic_atr_input { +u32 dst_ip; +u32 src_ip; +u16 src_port; +u16 dst_port; +}; + +struct hinic_fdir_rule { +struct hinic_hw_fdir_mask mask; +struct hinic_atr_input hinic_fdir;/* key of fdir filter */ +uint8_t queue;/* queue assigned when matched */ +}; + +extern const struct rte_flow_ops hinic_flow_ops; +/* hinic nic_device */ struct hinic_nic_dev {/* hardware device */
drivers/net/hinic/hinic_pmd_flow.c new file +1178 -0
1,178 lines not on this page · raw message
drivers/net/hinic/meson.build +1 -0
@@ -8,6 +8,7 @@ sources = files( 'hinic_pmd_ethdev.c', 'hinic_pmd_rx.c', 'hinic_pmd_tx.c', + 'hinic_pmd_flow.c', ) includes += include_directories('base')
Signature · 1 line
1.8.3.1
PATCH 9/15 net/hinic: create and destroy ntuple filter
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
Supports to create and destroy ntuple filter. The filter rule includes BGP and VRRP packet type.
--- drivers/net/hinic/hinic_pmd_ethdev.h | 72 ++++ drivers/net/hinic/hinic_pmd_flow.c | 699 ++++++++++++++++++++++++++++++++++- 2 files changed, 758 insertions(+), 13 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.h +72 -0
@@ -38,6 +38,54 @@ enum hinic_dev_status { HINIC_DEV_INTR_EN, }; +#define HINIC_MAX_Q_FILTERS 64/* hinic just support 64 filter types */ +#define HINIC_PKT_TYPE_FIND_ID (pkt_type) ((pkt_type) - HINIC_MAX_Q_FILTERS) + +struct hinic_5tuple_filter_info { +uint32_t dst_ip; +uint32_t src_ip; +uint16_t dst_port; +uint16_t src_port; +uint8_t proto;/* l4 protocol. */ +uint8_t priority;/* seven levels (001b-111b), 111b is highest, +* used when more than one filter matches. +*/ +uint8_t dst_ip_mask:1 ,/* if mask is 1b, do not compare dst ip. */ + src_ip_mask:1 ,/* if mask is 1b, do not compare src ip. */ + dst_port_mask:1 ,/* if mask is 1b, do not compare dst port. */ + src_port_mask:1 ,/* if mask is 1b, do not compare src port. */ + proto_mask:1 ;/* if mask is 1b, do not compare protocol. */ +}; + +/* 5tuple filter structure */ +struct hinic_5tuple_filter { +TAILQ_ENTRY (hinic_5tuple_filter) entries; +uint16_t index;/* the index of 5tuple filter */ +struct hinic_5tuple_filter_info filter_info; +uint16_t queue;/* rx queue assigned to */ +}; + +TAILQ_HEAD (hinic_5tuple_filter_list, hinic_5tuple_filter); + +struct hinic_pkt_filter { +uint16_t pkt_proto; +/** +* If this filter is added by configuration, +* it should not be removed. +*/ +uint8_t qid; +bool enable; +}; + +/* Structure to store filters' info. */ +struct hinic_filter_info { +uint8_t pkt_type; +uint8_t qid; +uint64_t type_mask;/* Bit mask for every used filter */ +struct hinic_5tuple_filter_list fivetuple_list; +struct hinic_pkt_filter pkt_filters[HINIC_MAX_Q_FILTERS ]; +}; +/* Information about the fdir mode. */ struct hinic_hw_fdir_mask {uint32_t src_ipv4_mask;
@@ -60,6 +108,26 @@ struct hinic_fdir_rule {uint8_t queue;/* queue assigned when matched */ }; +/* ntuple filter list structure */ +struct hinic_ntuple_filter_ele { +TAILQ_ENTRY (hinic_ntuple_filter_ele) entries; +struct rte_eth_ntuple_filter filter_info; +}; + +struct rte_flow { +enum rte_filter_type filter_type; +void *rule; +}; + +/* hinic_flow memory list structure */ +struct hinic_flow_mem { +TAILQ_ENTRY (hinic_flow_mem) entries; +struct rte_flow *flow; +}; + +TAILQ_HEAD (hinic_ntuple_filter_list, hinic_ntuple_filter_ele); +TAILQ_HEAD (hinic_flow_mem_list, hinic_flow_mem); +extern const struct rte_flow_ops hinic_flow_ops;/* hinic nic_device */
@@ -94,6 +162,10 @@ struct hinic_nic_dev {* vf: the same with associate pf */ u32 default_cos; + +struct hinic_filter_info filter; +struct hinic_ntuple_filter_list filter_ntuple_list; + struct hinic_flow_mem_list hinic_flow_list; };#endif /* _HINIC_PMD_ETHDEV_H_ */
drivers/net/hinic/hinic_pmd_flow.c +686 -13
728 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 10/15 net/hinic: create and destroy fdir filter
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
Supports to create and destroy ntuple filter. The filter rule includes LACP,ARP and ICMP packet type.
--- drivers/net/hinic/hinic_pmd_ethdev.h | 17 +- drivers/net/hinic/hinic_pmd_flow.c | 424 +++++++++++++++++++++++++++++++++-- 2 files changed, 424 insertions(+), 17 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.h +16 -1
@@ -114,6 +114,18 @@ struct hinic_ntuple_filter_ele {struct rte_eth_ntuple_filter filter_info; }; +/* ethertype filter list structure */ +struct hinic_ethertype_filter_ele { +TAILQ_ENTRY (hinic_ethertype_filter_ele) entries; +struct rte_eth_ethertype_filter filter_info; +}; + +/* fdir filter list structure */ +struct hinic_fdir_rule_ele { +TAILQ_ENTRY (hinic_fdir_rule_ele) entries; +struct hinic_fdir_rule filter_info; +}; +struct rte_flow {enum rte_filter_type filter_type;void *rule;
@@ -126,8 +138,9 @@ struct hinic_flow_mem { };TAILQ_HEAD (hinic_ntuple_filter_list, hinic_ntuple_filter_ele); +TAILQ_HEAD (hinic_ethertype_filter_list, hinic_ethertype_filter_ele); +TAILQ_HEAD (hinic_fdir_rule_filter_list, hinic_fdir_rule_ele);TAILQ_HEAD (hinic_flow_mem_list, hinic_flow_mem); -extern const struct rte_flow_ops hinic_flow_ops;/* hinic nic_device */
@@ -165,6 +178,8 @@ struct hinic_nic_dev {struct hinic_filter_info filter;struct hinic_ntuple_filter_list filter_ntuple_list; +struct hinic_ethertype_filter_list filter_ethertype_list; +struct hinic_fdir_rule_filter_list filter_fdir_rule_list;struct hinic_flow_mem_list hinic_flow_list; };
drivers/net/hinic/hinic_pmd_flow.c +408 -16
472 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 11/15 net/hinic: flush fdir filter
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
Supports to flush fdir filter.
Destroy all flow rules associated with a port on hinic.
--- drivers/net/hinic/base/hinic_pmd_niccfg.c | 11 +- drivers/net/hinic/hinic_pmd_ethdev.c | 16 ++ drivers/net/hinic/hinic_pmd_ethdev.h | 3 + drivers/net/hinic/hinic_pmd_flow.c | 273 ++++++++++++++++++++++-------- 4 files changed, 231 insertions(+), 72 deletions(-)
drivers/net/hinic/base/hinic_pmd_niccfg.c +8 -3
@@ -1522,7 +1522,7 @@ int hinic_set_fdir_filter(void *hwdev, u8 filter_type, u8 qid, u8 type_enable,if (hinic_func_type (hwdev) ==TYPE_VF ) {PMD_DRV_LOG (WARNING ,"VF don't support FDIR" ); -return 0 ; +return -EINVAL ; }memset (&port_filer_cmd,0 ,sizeof (port_filer_cmd));
@@ -1560,7 +1560,7 @@ int hinic_set_normal_filter(void *hwdev, u8 qid, u8 normal_type_enable,if (hinic_func_type (hwdev) ==TYPE_VF ) {PMD_DRV_LOG (WARNING ,"VF don't support FDIR" ); -return 0 ; +return -EINVAL ; }memset (&port_filer_cmd,0 ,sizeof (port_filer_cmd));
@@ -1599,7 +1599,7 @@ int hinic_set_fdir_tcam(void *hwdev, u16 type_mask,if (hinic_func_type (hwdev) ==TYPE_VF ) {PMD_DRV_LOG (WARNING ,"VF don't support set Tcam table" ); -return 0 ; +return -EINVAL ; }memset (&port_tcam_cmd,0 ,sizeof (port_tcam_cmd));
@@ -1632,6 +1632,11 @@ int hinic_clear_fdir_tcam(void *hwdev, u16 type_mask)if (!hwdev)return -EINVAL ; +if (hinic_func_type (hwdev) ==TYPE_VF ) { +PMD_DRV_LOG (WARNING ,"VF don't support FDIR" ); +return -EINVAL ; + } +memset (&port_tcam_cmd,0 ,sizeof (port_tcam_cmd)); port_tcam_cmd.mgmt_msg_head.resp_aeq_num =HINIC_AEQ1 ; port_tcam_cmd.tcam_index = type_mask;
drivers/net/hinic/hinic_pmd_ethdev.c +16 -0
@@ -334,6 +334,9 @@ static int hinic_dev_configure(struct rte_eth_dev *dev)return err; } +/*clear fdir filter flag in function table*/ +hinic_free_fdir_filter (nic_dev); +return HINIC_OK ; }
@@ -1101,6 +1104,8 @@ static void hinic_dev_stop(struct rte_eth_dev *dev)/* clean root context */ hinic_free_qp_ctxts (nic_dev->hwdev); +hinic_free_fdir_filter (nic_dev); +/* free mbuf */ hinic_free_all_rx_mbuf (dev);hinic_free_all_tx_mbuf (dev);
@@ -2769,6 +2774,7 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev)struct rte_pci_device *pci_dev;struct rte_ether_addr *eth_addr;struct hinic_nic_dev *nic_dev; +struct hinic_filter_info *filter_info;u32 mac_size;int rc;
@@ -2860,6 +2866,16 @@ static int hinic_func_init(struct rte_eth_dev *eth_dev) }hinic_set_bit (HINIC_DEV_INTR_EN , &nic_dev->dev_status); +/* initialize filter info */ + filter_info = &nic_dev->filter; +memset (filter_info,0 ,sizeof (struct hinic_filter_info )); +/* initialize 5tuple filter list */ +TAILQ_INIT (&filter_info->fivetuple_list); +TAILQ_INIT (&nic_dev->filter_ntuple_list); +TAILQ_INIT (&nic_dev->filter_ethertype_list); +TAILQ_INIT (&nic_dev->filter_fdir_rule_list); +TAILQ_INIT (&nic_dev->hinic_flow_list); +hinic_set_bit (HINIC_DEV_INIT , &nic_dev->dev_status);PMD_DRV_LOG (INFO ,"Initialize %s in primary successfully" , eth_dev->data->name);
drivers/net/hinic/hinic_pmd_ethdev.h +3 -0
@@ -141,6 +141,7 @@ struct hinic_flow_mem {TAILQ_HEAD (hinic_ethertype_filter_list, hinic_ethertype_filter_ele);TAILQ_HEAD (hinic_fdir_rule_filter_list, hinic_fdir_rule_ele);TAILQ_HEAD (hinic_flow_mem_list, hinic_flow_mem); +extern const struct rte_flow_ops hinic_flow_ops;/* hinic nic_device */
@@ -183,4 +184,6 @@ struct hinic_nic_dev { struct hinic_flow_mem_list hinic_flow_list; }; +void hinic_free_fdir_filter (struct hinic_nic_dev *nic_dev); +#endif /* _HINIC_PMD_ETHDEV_H_ */
drivers/net/hinic/hinic_pmd_flow.c +204 -69
439 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 12/15 net/hinic: set link down and up
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch supports setting link down and up.
--- drivers/net/hinic/base/hinic_pmd_cmd.h | 2 + drivers/net/hinic/base/hinic_pmd_niccfg.c | 28 ++++++++++++ drivers/net/hinic/base/hinic_pmd_niccfg.h | 13 ++++++ drivers/net/hinic/hinic_pmd_ethdev.c | 71 +++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+)
drivers/net/hinic/base/hinic_pmd_cmd.h +2 -0
@@ -85,6 +85,8 @@ enum hinic_port_cmd {HINIC_PORT_CMD_GET_JUMBO_FRAME_SIZE =0x4a ,HINIC_PORT_CMD_SET_JUMBO_FRAME_SIZE , +HINIC_PORT_CMD_GET_MGMT_VERSION =0x58 , +HINIC_PORT_CMD_GET_PORT_TYPE =0x5b , HINIC_PORT_CMD_GET_VPORT_ENABLE = 0x5c,
drivers/net/hinic/base/hinic_pmd_niccfg.c +28 -0
@@ -1162,6 +1162,34 @@ int hinic_set_rx_mode(void *hwdev, u32 enable)return 0 ; } +int hinic_get_fw_version (void *hwdev,char *fw) +{ +struct hinic_version_info fw_ver; +u16 out_size =sizeof (fw_ver); +int err; + +if (!hwdev || !fw) { +PMD_DRV_LOG (ERR ,"Hwdev or fw is NULL" ); +return -EINVAL ; + } + +memset (&fw_ver,0 ,sizeof (fw_ver)); + fw_ver.mgmt_msg_head.resp_aeq_num =HINIC_AEQ1 ; + + err =l2nic_msg_to_mgmt_sync (hwdev,HINIC_PORT_CMD_GET_MGMT_VERSION , + &fw_ver,sizeof (fw_ver), &fw_ver, + &out_size); +if (err || !out_size || fw_ver.mgmt_msg_head.status) { +PMD_DRV_LOG (ERR ,"Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n" , + err, fw_ver.mgmt_msg_head.status, out_size); +return -EINVAL ; + } + +snprintf (fw,HINIC_MGMT_VERSION_MAX_LEN ,"%s" , fw_ver.ver); + +return 0 ; +} +int hinic_set_rx_csum_offload (void *hwdev,u32 en) {struct hinic_checksum_offload rx_csum_cfg;
drivers/net/hinic/base/hinic_pmd_niccfg.h +13 -0
@@ -471,6 +471,17 @@ struct hinic_rx_mode_config {u32 rx_mode; }; +#define HINIC_MGMT_VERSION_MAX_LEN 32 +#define HINIC_COMPILE_TIME_LEN 20 +#define HINIC_FW_VERSION_NAME 16 + +struct hinic_version_info { +struct hinic_mgmt_msg_head mgmt_msg_head; + +u8 ver[HINIC_FW_VERSION_NAME ]; +u8 time[HINIC_COMPILE_TIME_LEN ]; +}; +/* rss */ struct nic_rss_indirect_tbl {u32 group_index;
@@ -803,6 +814,8 @@ int hinic_get_rss_type(void *hwdev, u32 tmpl_idx,int hinic_set_rx_mode (void *hwdev,u32 enable); +int hinic_get_fw_version (void *hwdev,char *fw); +int hinic_set_rx_csum_offload (void *hwdev,u32 en); int hinic_set_link_status_follow(void *hwdev,
drivers/net/hinic/hinic_pmd_ethdev.c +71 -0
98 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 13/15 net/hinic: support inner L3 checksum offload
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch supports inner L3 checksum offload.
--- drivers/net/hinic/hinic_pmd_tx.c | 192 ++++++++++++++++++++++++--------------- 1 file changed, 121 insertions(+), 71 deletions(-)
drivers/net/hinic/hinic_pmd_tx.c +121 -71
@@ -20,6 +20,9 @@#include "hinic_pmd_tx.h" /* packet header and tx offload info */ +#define ETHER_LEN_NO_VLAN 14 +#define ETHER_LEN_WITH_VLAN 18 +#define HEADER_LEN_OFFSET 2#define VXLANLEN 8#define MAX_PLD_OFFSET 221#define MAX_SINGLE_SGE_SIZE 65536
@@ -34,6 +37,9 @@#define HINIC_TSO_PKT_MAX_SGE 127/* tso max sge 127 */ #define HINIC_TSO_SEG_NUM_INVALID (num) ((num) > HINIC_TSO_PKT_MAX_SGE) +#define HINIC_TX_OUTER_CHECKSUM_FLAG_SET 1 +#define HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET 0 +/* sizeof(struct hinic_sq_bufdesc) == 16, shift 4 */ #define HINIC_BUF_DESC_SIZE (nr_descs) (SIZE_8BYTES(((u32)nr_descs) << 4))
@@ -476,16 +482,16 @@ static inline bool hinic_is_tso_sge_valid(struct rte_mbuf *mbuf, hinic_set_l4_csum_info(struct hinic_sq_task *task, u32 *queue_info, struct hinic_tx_offload_info *poff_info) { - u32 tcp_udp_cs, sctp; + u32 tcp_udp_cs, sctp = 0;u16 l2hdr_len; - sctp =0 ;if (unlikely (poff_info->inner_l4_type ==SCTP_OFFLOAD_ENABLE )) sctp =1 ; tcp_udp_cs = poff_info->inner_l4_tcp_udp; -if (poff_info->tunnel_type ==TUNNEL_UDP_NO_CSUM ) { +if (poff_info->tunnel_type ==TUNNEL_UDP_CSUM || + poff_info->tunnel_type ==TUNNEL_UDP_NO_CSUM ) { l2hdr_len = poff_info->outer_l2_len; task->pkt_info2 |=
@@ -665,50 +671,6 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)return (struct hinic_sq_wqe *)WQ_WQE_ADDR (wq, cur_pi); } -static inline int -hinic_validate_tx_offload (const struct rte_mbuf *m) -{ -uint64_t ol_flags = m->ol_flags; -uint64_t inner_l3_offset = m->l2_len; - -/* just support vxlan offload */ -if ((ol_flags &PKT_TX_TUNNEL_MASK ) && - !(ol_flags &PKT_TX_TUNNEL_VXLAN )) -return -ENOTSUP ; - -if (ol_flags &PKT_TX_OUTER_IP_CKSUM ) - inner_l3_offset += m->outer_l2_len + m->outer_l3_len; - -/* Headers are fragmented */ -if (rte_pktmbuf_data_len (m) < inner_l3_offset + m->l3_len + m->l4_len) -return -ENOTSUP ; - -/* IP checksum can be counted only for IPv4 packet */ -if ((ol_flags &PKT_TX_IP_CKSUM ) && (ol_flags &PKT_TX_IPV6 )) -return -EINVAL ; - -/* IP type not set when required */ -if (ol_flags & (PKT_TX_L4_MASK |PKT_TX_TCP_SEG )) { -if (!(ol_flags & (PKT_TX_IPV4 |PKT_TX_IPV6 ))) -return -EINVAL ; - } - -/* Check requirements for TSO packet */ -if (ol_flags &PKT_TX_TCP_SEG ) { -if (m->tso_segsz ==0 || - ((ol_flags &PKT_TX_IPV4 ) && - !(ol_flags &PKT_TX_IP_CKSUM ))) -return -EINVAL ; - } - -/* PKT_TX_OUTER_IP_CKSUM set for non outer IPv4 packet. */ -if ((ol_flags &PKT_TX_OUTER_IP_CKSUM ) && - !(ol_flags &PKT_TX_OUTER_IPV4 )) -return -EINVAL ; - -return 0 ; -} -static inline uint16_t hinic_ipv4_phdr_cksum (const struct rte_ipv4_hdr *ipv4_hdr,uint64_t ol_flags) {
@@ -760,6 +722,67 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)return __rte_raw_cksum_reduce (sum); } +static inline void +hinic_get_pld_offset (struct rte_mbuf *m,struct hinic_tx_offload_info *off_info, +int outer_cs_flag) +{ +uint64_t ol_flags = m->ol_flags; + +if (outer_cs_flag ==1 ) { +if ((ol_flags &PKT_TX_UDP_CKSUM ) ==PKT_TX_UDP_CKSUM ) { + off_info->payload_offset = m->outer_l2_len + + m->outer_l3_len + m->l2_len + m->l3_len; + }else if ((ol_flags &PKT_TX_TCP_CKSUM ) || + (ol_flags &PKT_TX_TCP_SEG )) { + off_info->payload_offset = m->outer_l2_len + + m->outer_l3_len + m->l2_len + + m->l3_len + m->l4_len; + } + }else { +if ((ol_flags &PKT_TX_UDP_CKSUM ) ==PKT_TX_UDP_CKSUM ) { + off_info->payload_offset = m->l2_len + m->l3_len; + }else if ((ol_flags &PKT_TX_TCP_CKSUM ) || + (ol_flags &PKT_TX_TCP_SEG )) { + off_info->payload_offset = m->l2_len + m->l3_len + + m->l4_len; + } + } +} + +static inline void +hinic_analyze_tx_info (struct rte_mbuf *mbuf, +struct hinic_tx_offload_info *off_info) +{ +struct rte_ether_hdr *eth_hdr; +struct rte_vlan_hdr *vlan_hdr; +struct rte_ipv4_hdr *ip4h; +u16 ethertype, l3_proto; +u8 *hdr; + + hdr = (u8 *)rte_pktmbuf_mtod(mbuf, u8*); + eth_hdr = (struct rte_ether_hdr *)hdr; + ethertype =rte_be_to_cpu_16 (eth_hdr->ether_type); + +if (ethertype ==RTE_ETHER_TYPE_VLAN ) { + off_info->outer_l2_len =ETHER_LEN_WITH_VLAN ; + vlan_hdr = (struct rte_vlan_hdr *)(hdr +1 ); + ethertype =rte_be_to_cpu_16 (vlan_hdr->eth_proto); + }else { + off_info->outer_l2_len =ETHER_LEN_NO_VLAN ; + } + + l3_proto = ethertype; + +if (l3_proto ==RTE_ETHER_TYPE_IPV4 ) { + ip4h = (struct rte_ipv4_hdr *)(hdr + off_info->outer_l2_len); + off_info->outer_l3_len = (ip4h->version_ihl &0xf ) << +HEADER_LEN_OFFSET ; + }else if (l3_proto ==RTE_ETHER_TYPE_IPV6 ) { +/* not support ipv6 extension header */ + off_info->outer_l3_len =sizeof (struct rte_ipv6_hdr ); + } +} +static inline int hinic_tx_offload_pkt_prepare (struct rte_mbuf *m,struct hinic_tx_offload_info *off_info)
@@ -771,42 +794,66 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq)struct rte_ether_hdr *eth_hdr;struct rte_vlan_hdr *vlan_hdr;u16 eth_type =0 ; -uint64_t inner_l3_offset = m->l2_len; +uint64_t inner_l3_offset;uint64_t ol_flags = m->ol_flags; -/* Does packet set any of available offloads */ +/* Check packet set any of available offloads */ if (!(ol_flags &HINIC_TX_CKSUM_OFFLOAD_MASK ))return 0 ; -if (unlikely (hinic_validate_tx_offload (m))) +/* just support vxlan offload */ +if ((ol_flags &PKT_TX_TUNNEL_MASK ) && + !(ol_flags &PKT_TX_TUNNEL_VXLAN )) +return -ENOTSUP ; + +#ifdef RTE_LIBRTE_ETHDEV_DEBUG +if (rte_validate_tx_offload (m) !=0 )return -EINVAL ; +#endif -if ((ol_flags &PKT_TX_OUTER_IP_CKSUM ) || - (ol_flags &PKT_TX_OUTER_IPV6 ) || - (ol_flags &PKT_TX_TUNNEL_VXLAN )) { - inner_l3_offset += m->outer_l2_len + m->outer_l3_len; - off_info->outer_l2_len = m->outer_l2_len; - off_info->outer_l3_len = m->outer_l3_len; -/* just support vxlan tunneling pkt */ - off_info->inner_l2_len = m->l2_len -VXLANLEN - -sizeof (struct rte_udp_hdr ); - off_info->inner_l3_len = m->l3_len; - off_info->inner_l4_len = m->l4_len; - off_info->tunnel_length = m->l2_len; - off_info->payload_offset = m->outer_l2_len + - m->outer_l3_len + m->l2_len + m->l3_len; - off_info->tunnel_type =TUNNEL_UDP_NO_CSUM ; +if (ol_flags &PKT_TX_TUNNEL_VXLAN ) { +if ((ol_flags &PKT_TX_OUTER_IP_CKSUM ) || + (ol_flags &PKT_TX_OUTER_IPV6 )) { + inner_l3_offset = m->l2_len + m->outer_l2_len + + m->outer_l3_len; + off_info->outer_l2_len = m->outer_l2_len; + off_info->outer_l3_len = m->outer_l3_len; +/* just support vxlan tunneling pkt */ + off_info->inner_l2_len = m->l2_len -VXLANLEN - +sizeof (*udp_hdr); + off_info->inner_l3_len = m->l3_len; + off_info->inner_l4_len = m->l4_len; + off_info->tunnel_length = m->l2_len; + off_info->tunnel_type =TUNNEL_UDP_NO_CSUM ; + +hinic_get_pld_offset (m, off_info, +HINIC_TX_OUTER_CHECKSUM_FLAG_SET ); + }else { + inner_l3_offset = m->l2_len; +hinic_analyze_tx_info (m, off_info); +/* just support vxlan tunneling pkt */ + off_info->inner_l2_len = m->l2_len -VXLANLEN - +sizeof (*udp_hdr) - off_info->outer_l2_len - + off_info->outer_l3_len; + off_info->inner_l3_len = m->l3_len; + off_info->inner_l4_len = m->l4_len; + off_info->tunnel_length = m->l2_len - + off_info->outer_l2_len - off_info->outer_l3_len; + off_info->tunnel_type =TUNNEL_UDP_NO_CSUM ; + +hinic_get_pld_offset (m, off_info, +HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET ); + } }else { + inner_l3_offset = m->l2_len; off_info->inner_l2_len = m->l2_len; off_info->inner_l3_len = m->l3_len; off_info->inner_l4_len = m->l4_len; off_info->tunnel_type =NOT_TUNNEL ; - off_info->payload_offset = m->l2_len + m->l3_len; - } -if (((ol_flags &PKT_TX_L4_MASK ) !=PKT_TX_SCTP_CKSUM ) && - ((ol_flags &PKT_TX_L4_MASK ) !=PKT_TX_UDP_CKSUM )) - off_info->payload_offset += m->l4_len; +hinic_get_pld_offset (m, off_info, +HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET ); + }/* invalid udp or tcp header */ if (unlikely (off_info->payload_offset >MAX_PLD_OFFSET ))
@@ -855,6 +902,10 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) udp_hdr->dgram_cksum =hinic_ipv6_phdr_cksum (ipv6_hdr, ol_flags); } + }else if (ol_flags &PKT_TX_OUTER_IPV4 ) { + off_info->tunnel_type =TUNNEL_UDP_NO_CSUM ; + off_info->inner_l4_tcp_udp =1 ; + off_info->outer_l3_type =IPV4_PKT_NO_CHKSUM_OFFLOAD ; }if (ol_flags &PKT_TX_IPV4 )
@@ -892,7 +943,6 @@ static inline void hinic_xmit_mbuf_cleanup(struct hinic_txq *txq) off_info->inner_l4_type =UDP_OFFLOAD_ENABLE ; off_info->inner_l4_tcp_udp =1 ; - off_info->inner_l4_len =sizeof (struct rte_udp_hdr ); }else if (((ol_flags &PKT_TX_L4_MASK ) ==PKT_TX_TCP_CKSUM ) || (ol_flags &PKT_TX_TCP_SEG )) {if (ol_flags &PKT_TX_IPV4 ) {
Signature · 1 line
1.8.3.1
PATCH 14/15 net/hinic: support LRO offload
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
This patch supports LRO offload.
--- drivers/net/hinic/hinic_pmd_ethdev.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/net/hinic/hinic_pmd_ethdev.c +19 -7
@@ -64,6 +64,9 @@#define HINIC_PKTLEN_TO_MTU (pktlen) \ ((pktlen) - (ETH_HLEN + ETH_CRC_LEN)) +/* lro numer limit for one packet */ +#define HINIC_LRO_WQE_NUM_DEFAULT 8 +/** Driver-specific log messages type. */ int hinic_logtype;
@@ -722,7 +725,8 @@ static void hinic_get_speed_capa(struct rte_eth_dev *dev, uint32_t *speed_capa)DEV_RX_OFFLOAD_TCP_CKSUM |DEV_RX_OFFLOAD_VLAN_FILTER |DEV_RX_OFFLOAD_SCATTER | -DEV_RX_OFFLOAD_JUMBO_FRAME ; +DEV_RX_OFFLOAD_JUMBO_FRAME | +DEV_RX_OFFLOAD_TCP_LRO ; info->tx_queue_offload_capa =0 ; info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
@@ -781,6 +785,7 @@ static int hinic_rxtx_configure(struct rte_eth_dev *dev) {int err;struct hinic_nic_dev *nic_dev =HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV (dev); +bool lro_en;/* rx configure, if rss enable, need to init default configuration */ err =hinic_rx_configure (dev);
@@ -797,6 +802,18 @@ static int hinic_rxtx_configure(struct rte_eth_dev *dev) goto set_rx_mode_fail; } +/* config lro */ + lro_en = dev->data->dev_conf.rxmode.offloads &DEV_RX_OFFLOAD_TCP_LRO ? + true : false; + + err =hinic_set_rx_lro (nic_dev->hwdev, lro_en, lro_en, +HINIC_LRO_WQE_NUM_DEFAULT ); +if (err) { +PMD_DRV_LOG (ERR ,"%s lro failed, err: %d" , + lro_en ?"Enable" :"Disable" , err); + goto set_rx_mode_fail; + } +return HINIC_OK ; set_rx_mode_fail:
@@ -2418,11 +2435,6 @@ static int hinic_set_default_hw_feature(struct hinic_nic_dev *nic_dev)if (err)return err; -/* disable LRO */ - err =hinic_set_rx_lro (nic_dev->hwdev,0 ,0 , (u8 )0 ); -if (err) -return err; -/* Set pause enable, and up will disable pfc. */ err =hinic_set_default_pause_feature (nic_dev);if (err)
@@ -2811,7 +2823,7 @@ static void hinic_dev_close(struct rte_eth_dev *dev)static const struct eth_dev_ops hinic_pmd_vf_ops = { .dev_configure = hinic_dev_configure, .dev_infos_get = hinic_dev_infos_get, - .fw_version_get = hinic_fw_version_get, + .fw_version_get = hinic_fw_version_get, .rx_queue_setup = hinic_rx_queue_setup, .tx_queue_setup = hinic_tx_queue_setup, .dev_start = hinic_dev_start,
Signature · 1 line
1.8.3.1
PATCH 15/15 net/hinic: add hinic PMD doc files
In reply to Ziyang XuanFrom: Xiaoyun Wang <[email protected]>
Add doc files about new features and modification.
--- doc/guides/nics/features/hinic.ini | 12 +++++++++++- doc/guides/nics/hinic.rst | 6 ++++++ doc/guides/rel_notes/release_19_11.rst | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
doc/guides/nics/features/hinic.ini +11 -1
@@ -9,16 +9,22 @@ Link status = Y Link status event = Y Free Tx mbuf on demand = Y Queue start/stop = Y -Jumbo frame = N +MTU update = Y +Jumbo frame = Y Scattered Rx = Y TSO = Y +LRO = Y Promiscuous mode = Y +Allmulticast mode = Y Unicast MAC filter = Y Multicast MAC filter = Y RSS hash = Y RSS key update = Y RSS reta update = Y Inner RSS = Y +SR-IOV = Y +VLAN filter = Y +VLAN offload = Y CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y
@@ -27,6 +33,10 @@ Inner L4 checksum = Y Basic stats = Y Extended stats = Y Stats per queue = Y +Flow director = Y +Flow control = Y +FW version = Y +Multiprocess aware = Y Linux UIO = Y Linux VFIO = Y BSD nic_uio = N
doc/guides/nics/hinic.rst +6 -0
@@ -24,6 +24,12 @@ Features - Link state information - Link flow control - Scattered and gather for TX and RX +- SR�CIOV - Partially supported at this point, VFIO only +- Allmulticast mode +- Unicast MAC filter +- Multicast MAC filter +- FW version +- Flow director Prerequisites -------------
doc/guides/rel_notes/release_19_11.rst +9 -0
@@ -56,6 +56,15 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Updated the Huawei hinic driver.** + + Updated the Huawei hinic driver with new features and improvements, including: + + * Enabled SR–IOV - Partially supported at this point, VFIO only. + * Supported VLAN filter and VLAN offload. + * Supported Unicast MAC filter and Multicast MAC filter. + * Supported FW version get. + * Supported Flow director for LACP, VRRP, BGP and so on. Removed Items -------------
Signature · 1 line
1.8.3.1