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_common.c | 4 +- drivers/net/zxdh/zxdh_ethdev.c | 33 +++++++----- drivers/net/zxdh/zxdh_ethdev_ops.c | 87 ++++++++++++++++++++++++++---- drivers/net/zxdh/zxdh_ethdev_ops.h | 3 ++ drivers/net/zxdh/zxdh_msg.c | 36 ++++++------- drivers/net/zxdh/zxdh_np.c | 26 ++++----- drivers/net/zxdh/zxdh_pci.c | 4 +- drivers/net/zxdh/zxdh_queue.h | 20 +++---- drivers/net/zxdh/zxdh_rxtx.c | 8 +-- drivers/net/zxdh/zxdh_tables.c | 46 +++++++++++++++- drivers/net/zxdh/zxdh_tables.h | 4 ++ 13 files changed, 198 insertions(+), 76 deletions(-) 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_common.c b/drivers/net/zxdh/zxdh_common.c index 75883a8897..3e9c044fe7 100644 --- a/drivers/net/zxdh/zxdh_common.c +++ b/drivers/net/zxdh/zxdh_common.c @@ -216,7 +216,7 @@ zxdh_get_res_info(struct zxdh_res_para *dev, uint8_t field, uint8_t *res, uint16 if (ret != ZXDH_BAR_MSG_OK) { PMD_DRV_LOG(ERR, - "send sync_msg failed. pcieid: 0x%x, ret: %d.", dev->pcie_id, ret); + "send sync_msg failed. pcieid: 0x%x, ret: %d", dev->pcie_id, ret); return ret; } struct zxdh_tbl_msg_reps_header *tbl_reps = @@ -224,7 +224,7 @@ zxdh_get_res_info(struct zxdh_res_para *dev, uint8_t field, uint8_t *res, uint16 if (tbl_reps->check != ZXDH_TBL_MSG_PRO_SUCCESS) { PMD_DRV_LOG(ERR, - "get resource_field failed. pcieid: 0x%x, ret: %d.", dev->pcie_id, ret); + "get resource_field failed. pcieid: 0x%x, ret: %d", dev->pcie_id, ret); return ret; } *len = tbl_reps->len; diff --git a/drivers/net/zxdh/zxdh_ethdev.c b/drivers/net/zxdh/zxdh_ethdev.c index d87ad15824..c177b1c6d7 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); @@ -255,7 +259,7 @@ zxdh_setup_risc_interrupts(struct rte_eth_dev *dev) uint8_t i; if (!hw->risc_intr) { - PMD_DRV_LOG(ERR, " to allocate risc_intr"); + PMD_DRV_LOG(ERR, "to allocate risc_intr"); hw->risc_intr = rte_zmalloc("risc_intr", ZXDH_MSIX_INTR_MSG_VEC_NUM * sizeof(struct rte_intr_handle), 0); if (hw->risc_intr == NULL) { @@ -821,7 +825,7 @@ zxdh_rss_qid_config(struct rte_eth_dev *dev) attr_msg->value = hw->channel_context[0].ph_chno & 0xfff; 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 ", + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d", hw->vport.vport, ZXDH_PORT_BASE_QID_FLAG); return ret; } @@ -887,7 +891,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev) if (nr_vq == hw->queue_num) goto end; - PMD_DRV_LOG(DEBUG, "queue changed need reset "); + PMD_DRV_LOG(DEBUG, "queue changed need reset"); /* Reset the device although not necessary at startup */ zxdh_pci_reset(hw); @@ -1030,13 +1034,13 @@ zxdh_dev_close(struct rte_eth_dev *dev) ret = zxdh_dev_stop(dev); if (ret != 0) { - PMD_DRV_LOG(ERR, " stop port %s failed.", dev->device->name); + PMD_DRV_LOG(ERR, "stop port %s failed", dev->device->name); return -1; } ret = zxdh_tables_uninit(dev); if (ret != 0) { - PMD_DRV_LOG(ERR, "%s :tables uninit %s failed ", __func__, dev->device->name); + PMD_DRV_LOG(ERR, "%s :tables uninit %s failed", __func__, dev->device->name); return -1; } @@ -1063,11 +1067,11 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev) struct zxdh_hw *hw = eth_dev->data->dev_private; if (!zxdh_pci_packed_queue(hw)) { - PMD_DRV_LOG(ERR, " port %u not support packed queue", eth_dev->data->port_id); + PMD_DRV_LOG(ERR, "port %u not support packed queue", eth_dev->data->port_id); return -1; } if (!zxdh_pci_with_feature(hw, ZXDH_NET_F_MRG_RXBUF)) { - PMD_DRV_LOG(ERR, " port %u not support rx mergeable", eth_dev->data->port_id); + PMD_DRV_LOG(ERR, "port %u not support rx mergeable", eth_dev->data->port_id); return -1; } eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare; @@ -1134,7 +1138,7 @@ zxdh_dev_start(struct rte_eth_dev *dev) ret = zxdh_mac_config(hw->eth_dev); if (ret) - PMD_DRV_LOG(ERR, " mac config failed"); + PMD_DRV_LOG(ERR, "mac config failed"); for (i = 0; i < dev->data->nb_rx_queues; i++) dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED; @@ -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 @@ -1184,7 +1189,7 @@ zxdh_init_device(struct rte_eth_dev *eth_dev) ret = zxdh_read_pci_caps(pci_dev, hw); if (ret) { - PMD_DRV_LOG(ERR, "port 0x%x pci caps read failed .", hw->port_id); + PMD_DRV_LOG(ERR, "port 0x%x pci caps read failed", hw->port_id); goto err; } @@ -1397,14 +1402,14 @@ zxdh_np_init(struct rte_eth_dev *eth_dev) if (hw->is_pf) { ret = zxdh_np_dtb_res_init(eth_dev); if (ret) { - PMD_DRV_LOG(ERR, "np dtb init failed, ret:%d ", ret); + PMD_DRV_LOG(ERR, "np dtb init failed, ret:%d", ret); return ret; } } if (zxdh_shared_data != NULL) zxdh_shared_data->np_init_done = 1; - PMD_DRV_LOG(DEBUG, "np init ok "); + PMD_DRV_LOG(DEBUG, "np init ok"); return 0; } @@ -1421,7 +1426,7 @@ zxdh_tables_init(struct rte_eth_dev *dev) ret = zxdh_panel_table_init(dev); if (ret) { - PMD_DRV_LOG(ERR, " panel table init failed"); + PMD_DRV_LOG(ERR, "panel table init failed"); return ret; } @@ -1433,7 +1438,7 @@ zxdh_tables_init(struct rte_eth_dev *dev) ret = zxdh_vlan_filter_table_init(dev); if (ret) { - PMD_DRV_LOG(ERR, " vlan filter table init failed"); + PMD_DRV_LOG(ERR, "vlan filter table init failed"); return ret; } @@ -1461,7 +1466,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev) memset(hw, 0, sizeof(*hw)); hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr; if (hw->bar_addr[0] == 0) { - PMD_DRV_LOG(ERR, "Bad mem resource."); + PMD_DRV_LOG(ERR, "Bad mem resource"); return -EIO; } diff --git a/drivers/net/zxdh/zxdh_ethdev_ops.c b/drivers/net/zxdh/zxdh_ethdev_ops.c index 1b219bd26d..cb0211083f 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 @@ -136,7 +137,7 @@ static int32_t zxdh_config_port_status(struct rte_eth_dev *dev, uint16_t link_st if (hw->is_pf) { ret = zxdh_get_port_attr(hw->vfid, &port_attr); if (ret) { - PMD_DRV_LOG(ERR, "write port_attr failed"); + PMD_DRV_LOG(ERR, "get port_attr failed"); return -1; } port_attr.is_up = link_status; @@ -258,7 +259,7 @@ int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete _ ret = zxdh_link_info_get(dev, &link); if (ret != 0) { - PMD_DRV_LOG(ERR, " Failed to get link status from hw"); + PMD_DRV_LOG(ERR, "Failed to get link status from hw"); return ret; } link.link_status &= hw->admin_status; @@ -267,7 +268,7 @@ int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete _ ret = zxdh_config_port_status(dev, link.link_status); if (ret != 0) { - PMD_DRV_LOG(ERR, "set port attr %d failed.", link.link_status); + PMD_DRV_LOG(ERR, "set port attr %d failed", link.link_status); return ret; } return rte_eth_linkstatus_set(dev, &link); @@ -317,7 +318,7 @@ int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *addr) zxdh_msg_head_build(hw, ZXDH_MAC_DEL, &msg_info); 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 ", + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d", hw->vport.vport, ZXDH_MAC_DEL); return ret; } @@ -330,7 +331,7 @@ int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *addr) zxdh_msg_head_build(hw, ZXDH_MAC_ADD, &msg_info); 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 ", + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d", hw->vport.vport, ZXDH_MAC_ADD); return ret; } @@ -666,13 +667,13 @@ zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) if (on) { if (dev->data->vlan_filter_conf.ids[idx] & (1ULL << bit_idx)) { - PMD_DRV_LOG(ERR, "vlan:%d has already added.", vlan_id); + PMD_DRV_LOG(ERR, "vlan:%d has already added", vlan_id); return 0; } msg_type = ZXDH_VLAN_FILTER_ADD; } else { if (!(dev->data->vlan_filter_conf.ids[idx] & (1ULL << bit_idx))) { - PMD_DRV_LOG(ERR, "vlan:%d has already deleted.", vlan_id); + PMD_DRV_LOG(ERR, "vlan:%d has already deleted", vlan_id); return 0; } msg_type = ZXDH_VLAN_FILTER_DEL; @@ -681,7 +682,7 @@ zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) if (hw->is_pf) { ret = zxdh_vlan_filter_table_set(hw->vport.vport, vlan_id, on); if (ret) { - PMD_DRV_LOG(ERR, "vlan_id:%d table set failed.", vlan_id); + PMD_DRV_LOG(ERR, "vlan_id:%d table set failed", vlan_id); return -1; } } else { @@ -690,7 +691,7 @@ zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) msg.data.vlan_filter_msg.vlan_id = vlan_id; ret = zxdh_vf_send_msg_to_pf(dev, &msg, sizeof(struct zxdh_msg_info), NULL, 0); if (ret) { - PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d ", + PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d", hw->vport.vport, msg_type); return ret; } @@ -1399,8 +1400,8 @@ zxdh_hw_np_stats_get(struct rte_eth_dev *dev, struct zxdh_hw_np_stats *np_stats &reply_info, sizeof(struct zxdh_msg_reply_info)); if (ret) { PMD_DRV_LOG(ERR, - "Failed to send msg: port 0x%x msg type ZXDH_PORT_METER_STAT_GET", - hw->vport.vport); + "%s Failed to send msg: port 0x%x msg type", + __func__, hw->vport.vport); return -1; } memcpy(np_stats, &reply_info.reply_body.np_stats, sizeof(struct zxdh_hw_np_stats)); @@ -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 failed ret:%d", ret); + return ret; + } + + ret = zxdh_get_port_attr(vfid, &vport_att); + if (ret != 0) { + PMD_DRV_LOG(ERR, + "[vfid:%d] zxdh_dev_mtu, get vport failed ret:%d", vfid, ret); + return ret; + } + + 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 failed 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_msg.c b/drivers/net/zxdh/zxdh_msg.c index a6e19bbdd8..9471c74fac 100644 --- a/drivers/net/zxdh/zxdh_msg.c +++ b/drivers/net/zxdh/zxdh_msg.c @@ -417,30 +417,30 @@ zxdh_bar_chan_send_para_check(struct zxdh_pci_bar_msg *in, uint8_t dst_index = 0; if (in == NULL || result == NULL) { - PMD_MSG_LOG(ERR, "send para ERR: null para."); + PMD_MSG_LOG(ERR, "send para ERR: null para"); return ZXDH_BAR_MSG_ERR_NULL_PARA; } src_index = zxdh_bar_msg_src_index_trans(in->src); dst_index = zxdh_bar_msg_dst_index_trans(in->dst); if (src_index == ZXDH_BAR_MSG_SRC_ERR || dst_index == ZXDH_BAR_MSG_DST_ERR) { - PMD_MSG_LOG(ERR, "send para ERR: chan doesn't exist."); + PMD_MSG_LOG(ERR, "send para ERR: chan doesn't exist"); return ZXDH_BAR_MSG_ERR_TYPE; } if (in->module_id >= ZXDH_BAR_MSG_MODULE_NUM) { - PMD_MSG_LOG(ERR, "send para ERR: invalid module_id: %d.", in->module_id); + PMD_MSG_LOG(ERR, "send para ERR: invalid module_id: %d", in->module_id); return ZXDH_BAR_MSG_ERR_MODULE; } if (in->payload_addr == NULL) { - PMD_MSG_LOG(ERR, "send para ERR: null message."); + PMD_MSG_LOG(ERR, "send para ERR: null message"); return ZXDH_BAR_MSG_ERR_BODY_NULL; } if (in->payload_len > ZXDH_BAR_MSG_PAYLOAD_MAX_LEN) { - PMD_MSG_LOG(ERR, "send para ERR: len %d is too long.", in->payload_len); + PMD_MSG_LOG(ERR, "send para ERR: len %d is too long", in->payload_len); return ZXDH_BAR_MSG_ERR_LEN; } if (in->virt_addr == 0 || result->recv_buffer == NULL) { - PMD_MSG_LOG(ERR, "send para ERR: virt_addr or recv_buffer is NULL."); + PMD_MSG_LOG(ERR, "send para ERR: virt_addr or recv_buffer is NULL"); return ZXDH_BAR_MSG_ERR_VIRTADDR_NULL; } if (result->buffer_len < ZXDH_REPS_HEADER_PAYLOAD_OFFSET) @@ -508,13 +508,13 @@ zxdh_bar_chan_lock(uint8_t src, uint8_t dst, uint16_t src_pcieid, uint64_t virt_ uint8_t dst_index = zxdh_bar_msg_dst_index_trans(dst); if (src_index == ZXDH_BAR_MSG_SRC_ERR || dst_index == ZXDH_BAR_MSG_DST_ERR) { - PMD_MSG_LOG(ERR, "lock ERR: chan doesn't exist."); + PMD_MSG_LOG(ERR, "lock ERR: chan doesn't exist"); return ZXDH_BAR_MSG_ERR_TYPE; } ret = zxdh_bar_hard_lock(src_pcieid, dst, virt_addr); if (ret != 0) - PMD_MSG_LOG(ERR, "dev: 0x%x failed to lock.", src_pcieid); + PMD_MSG_LOG(ERR, "dev: 0x%x failed to lock", src_pcieid); return ret; } @@ -526,7 +526,7 @@ zxdh_bar_chan_unlock(uint8_t src, uint8_t dst, uint16_t src_pcieid, uint64_t vir uint8_t dst_index = zxdh_bar_msg_dst_index_trans(dst); if (src_index == ZXDH_BAR_MSG_SRC_ERR || dst_index == ZXDH_BAR_MSG_DST_ERR) { - PMD_MSG_LOG(ERR, "unlock ERR: chan doesn't exist."); + PMD_MSG_LOG(ERR, "unlock ERR: chan doesn't exist"); return ZXDH_BAR_MSG_ERR_TYPE; } @@ -775,7 +775,7 @@ zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in, struct zxdh_msg_recvive if (time_out_cnt == ZXDH_BAR_MSG_TIMEOUT_TH && valid != ZXDH_BAR_MSG_CHAN_USABLE) { zxdh_bar_chan_msg_valid_set(subchan_addr, ZXDH_BAR_MSG_CHAN_USABLE); zxdh_bar_chan_msg_poltag_set(subchan_addr, 0); - PMD_MSG_LOG(ERR, "BAR MSG ERR: chan type time out."); + PMD_MSG_LOG(ERR, "BAR MSG ERR: chan type time out"); ret = ZXDH_BAR_MSG_ERR_TIME_OUT; } else { ret = zxdh_bar_chan_sync_msg_reps_get(subchan_addr, @@ -843,11 +843,11 @@ zxdh_bar_chan_enable(struct zxdh_msix_para *para, uint16_t *vport) sum_res = zxdh_bar_get_sum((uint8_t *)&msix_msg, sizeof(msix_msg)); if (check_token != sum_res) { - PMD_MSG_LOG(ERR, "expect token: 0x%x, get token: 0x%x.", sum_res, check_token); + PMD_MSG_LOG(ERR, "expect token: 0x%x, get token: 0x%x", sum_res, check_token); return ZXDH_BAR_MSG_ERR_REPLY; } *vport = recv_msg.msix_reps.vport; - PMD_MSG_LOG(DEBUG, "vport of pcieid: 0x%x get success.", para->pcie_id); + PMD_MSG_LOG(DEBUG, "vport of pcieid: 0x%x get success", para->pcie_id); return ZXDH_BAR_MSG_OK; } @@ -967,19 +967,19 @@ zxdh_bar_chan_msg_header_check(struct zxdh_bar_msg_header *msg_header) uint8_t module_id = 0; if (msg_header->valid != ZXDH_BAR_MSG_CHAN_USED) { - PMD_MSG_LOG(ERR, "recv header ERR: valid label is not used."); + PMD_MSG_LOG(ERR, "recv header ERR: valid label is not used"); return ZXDH_BAR_MSG_ERR_MODULE; } module_id = msg_header->module_id; if (module_id >= (uint8_t)ZXDH_BAR_MSG_MODULE_NUM) { - PMD_MSG_LOG(ERR, "recv header ERR: invalid module_id: %u.", module_id); + PMD_MSG_LOG(ERR, "recv header ERR: invalid module_id: %u", module_id); return ZXDH_BAR_MSG_ERR_MODULE; } len = msg_header->len; if (len > ZXDH_BAR_MSG_PAYLOAD_MAX_LEN) { - PMD_MSG_LOG(ERR, "recv header ERR: invalid mesg len: %u.", len); + PMD_MSG_LOG(ERR, "recv header ERR: invalid mesg len: %u", len); return ZXDH_BAR_MSG_ERR_LEN; } if (msg_recv_func_tbl[msg_header->module_id] == NULL) { @@ -1001,7 +1001,7 @@ zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev) recv_addr = zxdh_recv_addr_get(src, dst, virt_addr); if (recv_addr == 0) { - PMD_MSG_LOG(ERR, "invalid driver type(src:%u, dst:%u).", src, dst); + PMD_MSG_LOG(ERR, "invalid driver type(src:%u, dst:%u)", src, dst); return -1; } @@ -1009,13 +1009,13 @@ zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev) ret = zxdh_bar_chan_msg_header_check(&msg_header); if (ret != ZXDH_BAR_MSG_OK) { - PMD_MSG_LOG(ERR, "recv msg_head err, ret: %u.", ret); + PMD_MSG_LOG(ERR, "recv msg_head err, ret: %u", ret); return -1; } recved_msg = rte_malloc(NULL, msg_header.len, 0); if (recved_msg == NULL) { - PMD_MSG_LOG(ERR, "malloc temp buff failed."); + PMD_MSG_LOG(ERR, "malloc temp buff failed"); return -1; } zxdh_bar_chan_msg_payload_get(recv_addr, recved_msg, msg_header.len); diff --git a/drivers/net/zxdh/zxdh_np.c b/drivers/net/zxdh/zxdh_np.c index 42679635f4..74c0fc3ad7 100644 --- a/drivers/net/zxdh/zxdh_np.c +++ b/drivers/net/zxdh/zxdh_np.c @@ -188,7 +188,7 @@ static uint32_t zxdh_np_dev_init(void) { if (g_dev_mgr.is_init) { - PMD_DRV_LOG(ERR, "Dev is already initialized."); + PMD_DRV_LOG(ERR, "Dev is already initialized"); return 0; } @@ -209,14 +209,14 @@ zxdh_np_dev_add(uint32_t dev_id, ZXDH_DEV_TYPE_E dev_type, p_dev_mgr = &g_dev_mgr; if (!p_dev_mgr->is_init) { - PMD_DRV_LOG(ERR, "ErrorCode[ 0x%x]: Device Manager is not init!!!", + PMD_DRV_LOG(ERR, "ErrorCode[ 0x%x]: Device Manager is not init!", ZXDH_RC_DEV_MGR_NOT_INIT); return ZXDH_RC_DEV_MGR_NOT_INIT; } if (p_dev_mgr->p_dev_array[dev_id] != NULL) { /* device is already exist. */ - PMD_DRV_LOG(ERR, "Device is added again!!!"); + PMD_DRV_LOG(ERR, "Device is added again!"); p_dev_info = p_dev_mgr->p_dev_array[dev_id]; } else { /* device is new. */ @@ -907,7 +907,7 @@ zxdh_np_online_uninit(uint32_t dev_id, rc = zxdh_np_dtb_queue_release(dev_id, port_name, queue_id); if (rc != 0) PMD_DRV_LOG(ERR, "%s:dtb release error," - "port name %s queue id %d. ", __func__, port_name, queue_id); + "port name %s queue id %d", __func__, port_name, queue_id); zxdh_np_dtb_mgr_destroy(dev_id); zxdh_np_tlb_mgr_destroy(dev_id); @@ -1030,7 +1030,7 @@ zxdh_np_dtb_se_smmu0_ind_write(uint32_t dev_id, case ZXDH_ERAM128_OPR_128b: { if ((0xFFFFFFFF - (base_addr)) < (index)) { - PMD_DRV_LOG(ERR, "ICM %s:%d[Error:VALUE[val0=0x%x]" + PMD_DRV_LOG(ERR, "ICM %s:%d[Error:VALUE[val0=0x%x]" "INVALID] [val1=0x%x] ! FUNCTION :%s !", __FILE__, __LINE__, base_addr, index, __func__); @@ -1067,7 +1067,7 @@ zxdh_np_dtb_se_smmu0_ind_write(uint32_t dev_id, dtb_ind_addr = ((base_addr << 7) & ZXDH_ERAM128_BADDR_MASK) + temp_idx; - PMD_DRV_LOG(INFO, " dtb eram item 1bit addr: 0x%x", dtb_ind_addr); + PMD_DRV_LOG(INFO, "dtb eram item 1bit addr: 0x%x", dtb_ind_addr); rc = zxdh_np_dtb_smmu0_write_entry_data(dev_id, wrt_mode, @@ -1314,7 +1314,7 @@ zxdh_np_dtb_tab_down_info_set(uint32_t dev_id, uint32_t rc; if (ZXDH_DTB_QUEUE_INIT_FLAG_GET(dev_id, queue_id) == 0) { - PMD_DRV_LOG(ERR, "dtb queue %d is not init.", queue_id); + PMD_DRV_LOG(ERR, "dtb queue %d is not init", queue_id); return ZXDH_RC_DTB_QUEUE_IS_NOT_INIT; } @@ -1447,7 +1447,7 @@ zxdh_np_dtb_table_entry_write(uint32_t dev_id, if (dtb_len > max_size) { rte_free(p_data_buff); rte_free(p_data_buff_ex); - PMD_DRV_LOG(ERR, " %s error dtb_len>%u!", __func__, + PMD_DRV_LOG(ERR, "%s error dtb_len > %u!", __func__, max_size); return ZXDH_RC_DTB_DOWN_LEN_INVALID; } @@ -1542,7 +1542,7 @@ zxdh_np_dtb_table_entry_delete(uint32_t dev_id, if (dtb_len > max_size) { rte_free(p_data_buff); rte_free(p_data_buff_ex); - PMD_DRV_LOG(ERR, " %s error dtb_len>%u!", __func__, + PMD_DRV_LOG(ERR, "%s error dtb_len>%u!", __func__, max_size); return ZXDH_RC_DTB_DOWN_LEN_INVALID; } @@ -1620,7 +1620,7 @@ zxdh_np_soft_sdt_tbl_get(uint32_t dev_id, uint32_t sdt_no, void *p_sdt_info) rc = zxdh_np_sdt_tbl_data_parser(sdt_tbl.data_high32, sdt_tbl.data_low32, p_sdt_info); if (rc != 0) - PMD_DRV_LOG(ERR, "dpp sdt [%d] tbl_data_parser error.", sdt_no); + PMD_DRV_LOG(ERR, "dpp sdt [%d] tbl_data_parser error", sdt_no); return rc; } @@ -1763,7 +1763,7 @@ zxdh_np_dtb_tab_up_info_set(uint32_t dev_id, } if (ZXDH_DTB_QUEUE_INIT_FLAG_GET(dev_id, queue_id) == 0) { - PMD_DRV_LOG(ERR, "dtb queue %d is not init.", queue_id); + PMD_DRV_LOG(ERR, "dtb queue %d is not init", queue_id); return ZXDH_RC_DTB_QUEUE_IS_NOT_INIT; } @@ -1829,7 +1829,7 @@ zxdh_np_dtb_tab_up_free_item_get(uint32_t dev_id, uint32_t i; if (ZXDH_DTB_QUEUE_INIT_FLAG_GET(dev_id, queue_id) == 0) { - PMD_DRV_LOG(ERR, "dtb queue %d is not init.", queue_id); + PMD_DRV_LOG(ERR, "dtb queue %d is not init", queue_id); return ZXDH_RC_DTB_QUEUE_IS_NOT_INIT; } @@ -1874,7 +1874,7 @@ zxdh_np_dtb_tab_up_item_addr_get(uint32_t dev_id, uint64_t addr; if (ZXDH_DTB_QUEUE_INIT_FLAG_GET(dev_id, queue_id) == 0) { - PMD_DRV_LOG(ERR, "dtb queue %d is not init.", queue_id); + PMD_DRV_LOG(ERR, "dtb queue %d is not init", queue_id); return ZXDH_RC_DTB_QUEUE_IS_NOT_INIT; } diff --git a/drivers/net/zxdh/zxdh_pci.c b/drivers/net/zxdh/zxdh_pci.c index 6b2c4482b2..959b1b8cff 100644 --- a/drivers/net/zxdh/zxdh_pci.c +++ b/drivers/net/zxdh/zxdh_pci.c @@ -254,7 +254,7 @@ zxdh_pci_get_features(struct zxdh_hw *hw) void zxdh_pci_reset(struct zxdh_hw *hw) { - PMD_DRV_LOG(INFO, "port %u device start reset, just wait...", hw->port_id); + PMD_DRV_LOG(INFO, "port %u device start reset, just wait", hw->port_id); uint32_t retry = 0; ZXDH_VTPCI_OPS(hw)->set_status(hw, ZXDH_CONFIG_STATUS_RESET); @@ -379,7 +379,7 @@ zxdh_read_pci_caps(struct rte_pci_device *dev, struct zxdh_hw *hw) } if (hw->common_cfg == NULL || hw->notify_base == NULL || hw->dev_cfg == NULL || hw->isr == NULL) { - PMD_DRV_LOG(ERR, "no zxdh pci device found."); + PMD_DRV_LOG(ERR, "no zxdh pci device found"); return -1; } return 0; diff --git a/drivers/net/zxdh/zxdh_queue.h b/drivers/net/zxdh/zxdh_queue.h index deb0dd891a..1a1994d965 100644 --- a/drivers/net/zxdh/zxdh_queue.h +++ b/drivers/net/zxdh/zxdh_queue.h @@ -65,7 +65,7 @@ struct zxdh_vring_desc { uint32_t len; /* Length. */ uint16_t flags; /* The flags as indicated above. */ uint16_t next; /* We chain unused descriptors via this. */ -} __rte_packed; +}; struct zxdh_vring_used_elem { /* Index of start of used descriptor chain. */ @@ -78,38 +78,38 @@ struct zxdh_vring_used { uint16_t flags; uint16_t idx; struct zxdh_vring_used_elem ring[]; -} __rte_packed; +}; struct zxdh_vring_avail { uint16_t flags; uint16_t idx; uint16_t ring[]; -} __rte_packed; +}; struct zxdh_vring_packed_desc { uint64_t addr; uint32_t len; uint16_t id; uint16_t flags; -} __rte_packed; +}; struct zxdh_vring_packed_desc_event { uint16_t desc_event_off_wrap; uint16_t desc_event_flags; -} __rte_packed; +}; struct zxdh_vring_packed { uint32_t num; struct zxdh_vring_packed_desc *desc; struct zxdh_vring_packed_desc_event *driver; struct zxdh_vring_packed_desc_event *device; -} __rte_packed; +}; struct zxdh_vq_desc_extra { void *cookie; uint16_t ndescs; uint16_t next; -} __rte_packed; +}; struct zxdh_virtqueue { struct zxdh_hw *hw; /* < zxdh_hw structure pointer. */ @@ -121,7 +121,7 @@ struct zxdh_virtqueue { uint16_t cached_flags; /* < cached flags for descs */ uint16_t event_flags_shadow; uint16_t rsv1; - } __rte_packed vq_packed; + } vq_packed; uint16_t vq_used_cons_idx; /* < last consumed descriptor */ uint16_t vq_nentries; /* < vring desc numbers */ uint16_t vq_free_cnt; /* < num of desc available */ @@ -154,7 +154,7 @@ struct zxdh_virtqueue { uint16_t *notify_addr; struct rte_mbuf **sw_ring; /* < RX software ring. */ struct zxdh_vq_desc_extra vq_descx[]; -} __rte_packed; +}; struct zxdh_type_hdr { uint8_t port; /* bit[0:1] 00-np 01-DRS 10-DTP */ @@ -227,7 +227,7 @@ struct zxdh_tx_region { union { struct zxdh_vring_desc tx_indir[ZXDH_MAX_TX_INDIRECT]; struct zxdh_vring_packed_desc tx_packed_indir[ZXDH_MAX_TX_INDIRECT]; - } __rte_packed; + }; }; static inline size_t diff --git a/drivers/net/zxdh/zxdh_rxtx.c b/drivers/net/zxdh/zxdh_rxtx.c index 27a61d46dd..6353d496f2 100644 --- a/drivers/net/zxdh/zxdh_rxtx.c +++ b/drivers/net/zxdh/zxdh_rxtx.c @@ -494,7 +494,7 @@ zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkt } } if (txm->nb_segs > ZXDH_TX_MAX_SEGS) { - PMD_TX_LOG(ERR, "%d segs dropped", txm->nb_segs); + PMD_TX_LOG(ERR, "%d segs dropped", txm->nb_segs); txvq->stats.truncated_err += nb_pkts - nb_tx; break; } @@ -727,7 +727,7 @@ uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, if (!seg_res) { if (rcvd_pkt_len != rx_pkts[nb_rx]->pkt_len) { - PMD_RX_LOG(ERR, "dropped rcvd_pkt_len %d pktlen %d.", + PMD_RX_LOG(ERR, "dropped rcvd_pkt_len %d pktlen %d", rcvd_pkt_len, rx_pkts[nb_rx]->pkt_len); zxdh_discard_rxbuf(vq, rx_pkts[nb_rx]); rxvq->stats.errors++; @@ -745,7 +745,7 @@ uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, rcv_cnt = zxdh_dequeue_burst_rx_packed(vq, rcv_pkts, len, rcv_cnt); if (unlikely(rcv_cnt == 0)) { - PMD_RX_LOG(ERR, "No enough segments for packet."); + PMD_RX_LOG(ERR, "No enough segments for packet"); rte_pktmbuf_free(rx_pkts[nb_rx]); rxvq->stats.errors++; break; @@ -764,7 +764,7 @@ uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, seg_res -= rcv_cnt; if (!seg_res) { if (rcvd_pkt_len != rx_pkts[nb_rx]->pkt_len) { - PMD_RX_LOG(ERR, "dropped rcvd_pkt_len %d pktlen %d.", + PMD_RX_LOG(ERR, "dropped rcvd_pkt_len %d pktlen %d", rcvd_pkt_len, rx_pkts[nb_rx]->pkt_len); zxdh_discard_rxbuf(vq, rx_pkts[nb_rx]); rxvq->stats.errors++; diff --git a/drivers/net/zxdh/zxdh_tables.c b/drivers/net/zxdh/zxdh_tables.c index 2939d9ae8b..fe228e2227 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) { @@ -160,7 +202,7 @@ zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr) ret = zxdh_np_dtb_table_entry_get(ZXDH_DEVICE_NO, g_dtb_data.queueid, &user_entry_get, 1); if (ret != 0) - PMD_DRV_LOG(ERR, "get port_attr vfid:%d failed, ret:%d ", vfid, ret); + PMD_DRV_LOG(ERR, "get port_attr vfid:%d failed, ret:%d", vfid, ret); return ret; } @@ -529,7 +571,7 @@ zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable) ret = zxdh_np_dtb_table_entry_write(ZXDH_DEVICE_NO, g_dtb_data.queueid, 1, &entry); if (ret) { - PMD_DRV_LOG(ERR, "unicast_table_set_failed:%d", hw->vfid); + PMD_DRV_LOG(ERR, "unicast_table_set_failed:%d", hw->vfid); return -ret; } return 0; 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