mtu update ops implementations. Signed-off-by: Junlong Wang --- doc/guides/nics/features/zxdh.ini | 1 + doc/guides/nics/zxdh.rst | 2 + drivers/net/zxdh/zxdh_ethdev.c | 5 +++ drivers/net/zxdh/zxdh_ethdev_ops.c | 65 ++++++++++++++++++++++++++++++ drivers/net/zxdh/zxdh_ethdev_ops.h | 3 ++ drivers/net/zxdh/zxdh_tables.c | 42 +++++++++++++++++++ drivers/net/zxdh/zxdh_tables.h | 4 ++ 7 files changed, 122 insertions(+) diff --git a/doc/guides/nics/features/zxdh.ini b/doc/guides/nics/features/zxdh.ini index 98c141cf95..3561e31666 100644 --- a/doc/guides/nics/features/zxdh.ini +++ b/doc/guides/nics/features/zxdh.ini @@ -24,3 +24,4 @@ RSS reta update = Y Inner RSS = Y Basic stats = Y Stats per queue = Y +MTU update = Y diff --git a/doc/guides/nics/zxdh.rst b/doc/guides/nics/zxdh.rst index c8a52b587c..58e0c49a2e 100644 --- a/doc/guides/nics/zxdh.rst +++ b/doc/guides/nics/zxdh.rst @@ -33,6 +33,8 @@ Features of the ZXDH PMD are: - QINQ stripping and inserting - Receive Side Scaling (RSS) - Port hardware statistics +- MTU update +- Jumbo frames Driver compilation and testing diff --git a/drivers/net/zxdh/zxdh_ethdev.c b/drivers/net/zxdh/zxdh_ethdev.c index d87ad15824..e992c3f6cf 100644 --- a/drivers/net/zxdh/zxdh_ethdev.c +++ b/drivers/net/zxdh/zxdh_ethdev.c @@ -64,6 +64,10 @@ zxdh_dev_infos_get(struct rte_eth_dev *dev, dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_256; dev_info->flow_type_rss_offloads = ZXDH_RSS_HF; + dev_info->max_mtu = ZXDH_MAX_RX_PKTLEN - RTE_ETHER_HDR_LEN - + RTE_VLAN_HLEN - ZXDH_DL_NET_HDR_SIZE; + dev_info->min_mtu = ZXDH_ETHER_MIN_MTU; + dev_info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS); dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO); @@ -1173,6 +1177,7 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = { .rss_hash_conf_get = zxdh_rss_hash_conf_get, .stats_get = zxdh_dev_stats_get, .stats_reset = zxdh_dev_stats_reset, + .mtu_set = zxdh_dev_mtu_set, }; static int32_t diff --git a/drivers/net/zxdh/zxdh_ethdev_ops.c b/drivers/net/zxdh/zxdh_ethdev_ops.c index 1b219bd26d..495e2432c7 100644 --- a/drivers/net/zxdh/zxdh_ethdev_ops.c +++ b/drivers/net/zxdh/zxdh_ethdev_ops.c @@ -13,6 +13,7 @@ #include "zxdh_logs.h" #include "zxdh_rxtx.h" #include "zxdh_np.h" +#include "zxdh_queue.h" #define ZXDH_VLAN_FILTER_GROUPS 64 #define ZXDH_INVALID_LOGIC_QID 0xFFFFU @@ -1506,3 +1507,67 @@ int zxdh_dev_stats_reset(struct rte_eth_dev *dev) return 0; } + +int zxdh_dev_mtu_set(struct rte_eth_dev *dev, uint16_t new_mtu) +{ + struct zxdh_hw *hw = dev->data->dev_private; + struct zxdh_panel_table panel = {0}; + struct zxdh_port_attr_table vport_att = {0}; + uint16_t vfid = zxdh_vport_to_vfid(hw->vport); + int ret; + + if (hw->is_pf) { + ret = zxdh_get_panel_attr(dev, &panel); + if (ret != 0) { + PMD_DRV_LOG(ERR, "get_panel_attr ret:%d", ret); + return -1; + } + + ret = zxdh_get_port_attr(vfid, &vport_att); + if (ret != 0) { + PMD_DRV_LOG(ERR, + "[vfid:%d] zxdh_dev_mtu, get vport dpp_ret:%d", vfid, ret); + return -1; + } + + panel.mtu = new_mtu; + panel.mtu_enable = 1; + ret = zxdh_set_panel_attr(dev, &panel); + if (ret != 0) { + PMD_DRV_LOG(ERR, "set zxdh_dev_mtu failed, ret:%u", ret); + return ret; + } + + vport_att.mtu_enable = 1; + vport_att.mtu = new_mtu; + ret = zxdh_set_port_attr(vfid, &vport_att); + if (ret != 0) { + PMD_DRV_LOG(ERR, + "[vfid:%d] zxdh_dev_mtu, set vport dpp_ret:%d", vfid, ret); + return ret; + } + } else { + struct zxdh_msg_info msg_info = {0}; + struct zxdh_port_attr_set_msg *attr_msg = &msg_info.data.port_attr_msg; + + zxdh_msg_head_build(hw, ZXDH_PORT_ATTRS_SET, &msg_info); + attr_msg->mode = ZXDH_PORT_MTU_EN_FLAG; + attr_msg->value = 1; + ret = zxdh_vf_send_msg_to_pf(dev, &msg_info, sizeof(msg_info), NULL, 0); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d ", + hw->vport.vport, ZXDH_PORT_MTU_EN_FLAG); + return ret; + } + attr_msg->mode = ZXDH_PORT_MTU_FLAG; + attr_msg->value = new_mtu; + ret = zxdh_vf_send_msg_to_pf(dev, &msg_info, sizeof(msg_info), NULL, 0); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d ", + hw->vport.vport, ZXDH_PORT_MTU_FLAG); + return ret; + } + } + dev->data->mtu = new_mtu; + return 0; +} diff --git a/drivers/net/zxdh/zxdh_ethdev_ops.h b/drivers/net/zxdh/zxdh_ethdev_ops.h index f35378e691..fac6cbd5e8 100644 --- a/drivers/net/zxdh/zxdh_ethdev_ops.h +++ b/drivers/net/zxdh/zxdh_ethdev_ops.h @@ -26,6 +26,8 @@ #define ZXDH_HF_MAC_VLAN_ETH ZXDH_ETH_RSS_L2 #define ZXDH_RSS_HF ((ZXDH_HF_MAC_VLAN_ETH | ZXDH_HF_F3_ETH | ZXDH_HF_F5_ETH)) +#define ZXDH_ETHER_MIN_MTU 68 + struct zxdh_hw_vqm_stats { uint64_t rx_total; uint64_t tx_total; @@ -73,5 +75,6 @@ int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss int zxdh_rss_configure(struct rte_eth_dev *dev); int zxdh_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); int zxdh_dev_stats_reset(struct rte_eth_dev *dev); +int zxdh_dev_mtu_set(struct rte_eth_dev *dev, uint16_t new_mtu); #endif /* ZXDH_ETHDEV_OPS_H */ diff --git a/drivers/net/zxdh/zxdh_tables.c b/drivers/net/zxdh/zxdh_tables.c index 2939d9ae8b..d6cbde3a21 100644 --- a/drivers/net/zxdh/zxdh_tables.c +++ b/drivers/net/zxdh/zxdh_tables.c @@ -150,6 +150,48 @@ int zxdh_panel_table_init(struct rte_eth_dev *dev) return ret; } +int zxdh_get_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr) +{ + struct zxdh_hw *hw = dev->data->dev_private; + uint8_t index_phy_port = hw->phyport; + + ZXDH_DTB_ERAM_ENTRY_INFO_T panel_entry = { + .index = index_phy_port, + .p_data = (uint32_t *)panel_attr + }; + ZXDH_DTB_USER_ENTRY_T entry = { + .sdt_no = ZXDH_SDT_PANEL_ATT_TABLE, + .p_entry_data = (void *)&panel_entry + }; + int ret = zxdh_np_dtb_table_entry_get(ZXDH_DEVICE_NO, g_dtb_data.queueid, &entry, 1); + + if (ret != 0) + PMD_DRV_LOG(ERR, "get panel table failed"); + + return ret; +} + +int zxdh_set_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr) +{ + struct zxdh_hw *hw = dev->data->dev_private; + uint8_t index_phy_port = hw->phyport; + + ZXDH_DTB_ERAM_ENTRY_INFO_T panel_entry = { + .index = index_phy_port, + .p_data = (uint32_t *)panel_attr + }; + ZXDH_DTB_USER_ENTRY_T entry = { + .sdt_no = ZXDH_SDT_PANEL_ATT_TABLE, + .p_entry_data = (void *)&panel_entry + }; + int ret = zxdh_np_dtb_table_entry_write(ZXDH_DEVICE_NO, g_dtb_data.queueid, 1, &entry); + + if (ret) + PMD_DRV_LOG(ERR, "Insert panel table failed"); + + return ret; +} + int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr) { diff --git a/drivers/net/zxdh/zxdh_tables.h b/drivers/net/zxdh/zxdh_tables.h index c7da40f294..adedf3d0d3 100644 --- a/drivers/net/zxdh/zxdh_tables.h +++ b/drivers/net/zxdh/zxdh_tables.h @@ -8,8 +8,10 @@ #include #define ZXDH_DEVICE_NO 0 +#define ZXDH_PORT_MTU_FLAG 9 #define ZXDH_PORT_BASE_QID_FLAG 10 #define ZXDH_PORT_ATTR_IS_UP_FLAG 35 +#define ZXDH_PORT_MTU_EN_FLAG 42 #define ZXDH_MTU_STATS_EGRESS_BASE 0x8481 #define ZXDH_MTU_STATS_INGRESS_BASE 0x8981 @@ -223,5 +225,7 @@ int zxdh_vlan_filter_table_init(struct rte_eth_dev *dev); int zxdh_vlan_filter_table_set(uint16_t vport, uint16_t vlan_id, uint8_t enable); int zxdh_rss_table_set(uint16_t vport, struct zxdh_rss_reta *rss_reta); int zxdh_rss_table_get(uint16_t vport, struct zxdh_rss_reta *rss_reta); +int zxdh_get_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr); +int zxdh_set_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_attr); #endif /* ZXDH_TABLES_H */ -- 2.27.0