delete port tables in host.
Signed-off-by: Junlong Wang <wang.junlong1@zte.com.cn>
---
drivers/net/zxdh/zxdh_ethdev.c | 18 ++++++
drivers/net/zxdh/zxdh_msg.h | 1 +
drivers/net/zxdh/zxdh_np.c | 103 +++++++++++++++++++++++++++++++++
drivers/net/zxdh/zxdh_np.h | 9 +++
drivers/net/zxdh/zxdh_tables.c | 33 ++++++++++-
drivers/net/zxdh/zxdh_tables.h | 1 +
6 files changed, 164 insertions(+), 1 deletion(-)
diff --git a/drivers/net/zxdh/zxdh_ethdev.c b/drivers/net/zxdh/zxdh_ethdev.c
index ff44816384..717a1d2b0b 100644
--- a/drivers/net/zxdh/zxdh_ethdev.c
+++ b/drivers/net/zxdh/zxdh_ethdev.c
@@ -887,12 +887,30 @@ zxdh_np_uninit(struct rte_eth_dev *dev)
zxdh_np_dtb_data_res_free(hw);
}
+static int
+zxdh_tables_uninit(struct rte_eth_dev *dev)
+{
+ int ret;
+
+ ret = zxdh_port_attr_uninit(dev);
+ if (ret)
+ PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+
+ return ret;
+}
+
static int
zxdh_dev_close(struct rte_eth_dev *dev)
{
struct zxdh_hw *hw = dev->data->dev_private;
int ret = 0;
+ ret = zxdh_tables_uninit(dev);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "%s :tables uninit %s failed ", __func__, dev->device->name);
+ return -1;
+ }
+
zxdh_intr_release(dev);
zxdh_np_uninit(dev);
zxdh_pci_reset(hw);
diff --git a/drivers/net/zxdh/zxdh_msg.h b/drivers/net/zxdh/zxdh_msg.h
index b7b17b8696..613ca71170 100644
--- a/drivers/net/zxdh/zxdh_msg.h
+++ b/drivers/net/zxdh/zxdh_msg.h
@@ -167,6 +167,7 @@ enum pciebar_layout_type {
enum zxdh_msg_type {
ZXDH_NULL = 0,
ZXDH_VF_PORT_INIT = 1,
+ ZXDH_VF_PORT_UNINIT = 2,
ZXDH_MSG_TYPE_END,
};
diff --git a/drivers/net/zxdh/zxdh_np.c b/drivers/net/zxdh/zxdh_np.c
index db536d96e3..740d302f91 100644
--- a/drivers/net/zxdh/zxdh_np.c
+++ b/drivers/net/zxdh/zxdh_np.c
@@ -25,6 +25,7 @@ ZXDH_RISCV_DTB_MGR *p_riscv_dtb_queue_mgr[ZXDH_DEV_CHANNEL_MAX];
ZXDH_TLB_MGR_T *g_p_dpp_tlb_mgr[ZXDH_DEV_CHANNEL_MAX];
ZXDH_REG_T g_dpp_reg_info[4];
ZXDH_DTB_TABLE_T g_dpp_dtb_table_info[4];
+ZXDH_SDT_TBL_DATA_T g_sdt_info[ZXDH_DEV_CHANNEL_MAX][ZXDH_DEV_SDT_ID_MAX];
#define ZXDH_SDT_MGR_PTR_GET() (&g_sdt_mgr)
#define ZXDH_SDT_SOFT_TBL_GET(id) (g_sdt_mgr.sdt_tbl_array[id])
@@ -1454,3 +1455,105 @@ zxdh_np_dtb_table_entry_write(uint32_t dev_id,
return rc;
}
+
+static uint32_t
+zxdh_np_sdt_tbl_data_get(uint32_t dev_id, uint32_t sdt_no, ZXDH_SDT_TBL_DATA_T *p_sdt_data)
+{
+ uint32_t rc = 0;
+
+ p_sdt_data->data_high32 = g_sdt_info[dev_id][sdt_no].data_high32;
+ p_sdt_data->data_low32 = g_sdt_info[dev_id][sdt_no].data_low32;
+
+ return rc;
+}
+
+int
+zxdh_np_dtb_table_entry_delete(uint32_t dev_id,
+ uint32_t queue_id,
+ uint32_t entrynum,
+ ZXDH_DTB_USER_ENTRY_T *delete_entries)
+{
+ ZXDH_SDT_TBL_DATA_T sdt_tbl = {0};
+ ZXDH_DTB_USER_ENTRY_T *pentry = NULL;
+ ZXDH_DTB_ENTRY_T dtb_one_entry = {0};
+ uint8_t entry_cmd[ZXDH_DTB_TABLE_CMD_SIZE_BIT / 8] = {0};
+ uint8_t entry_data[ZXDH_ETCAM_WIDTH_MAX / 8] = {0};
+ uint8_t *p_data_buff = NULL;
+ uint8_t *p_data_buff_ex = NULL;
+ uint32_t tbl_type = 0;
+ uint32_t element_id = 0xff;
+ uint32_t one_dtb_len = 0;
+ uint32_t dtb_len = 0;
+ uint32_t entry_index;
+ uint32_t sdt_no;
+ uint32_t addr_offset;
+ uint32_t max_size;
+ uint32_t rc;
+
+ ZXDH_COMM_CHECK_POINT(delete_entries);
+
+ p_data_buff = rte_calloc(NULL, 1, ZXDH_DTB_TABLE_DATA_BUFF_SIZE, 0);
+ ZXDH_COMM_CHECK_POINT(p_data_buff);
+
+ p_data_buff_ex = rte_calloc(NULL, sizeof(uint8_t), ZXDH_DTB_TABLE_DATA_BUFF_SIZE, 0);
+ ZXDH_COMM_CHECK_POINT_MEMORY_FREE(p_data_buff_ex, p_data_buff);
+
+ dtb_one_entry.cmd = entry_cmd;
+ dtb_one_entry.data = entry_data;
+
+ max_size = (ZXDH_DTB_TABLE_DATA_BUFF_SIZE / 16) - 1;
+
+ for (entry_index = 0; entry_index < entrynum; entry_index++) {
+ pentry = delete_entries + entry_index;
+
+ sdt_no = pentry->sdt_no;
+ rc = zxdh_np_sdt_tbl_data_get(dev_id, sdt_no, &sdt_tbl);
+ switch (tbl_type) {
+ case ZXDH_SDT_TBLT_ERAM:
+ {
+ rc = zxdh_np_dtb_eram_one_entry(dev_id, sdt_no, ZXDH_DTB_ITEM_DELETE,
+ pentry->p_entry_data, &one_dtb_len, &dtb_one_entry);
+ break;
+ }
+ default:
+ {
+ PMD_DRV_LOG(ERR, "SDT table_type[ %d ] is invalid!", tbl_type);
+ rte_free(p_data_buff);
+ rte_free(p_data_buff_ex);
+ return 1;
+ }
+ }
+
+ addr_offset = dtb_len * ZXDH_DTB_LEN_POS_SETP;
+ dtb_len += one_dtb_len;
+ 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__,
+ max_size);
+ return ZXDH_RC_DTB_DOWN_LEN_INVALID;
+ }
+
+ rc = zxdh_np_dtb_data_write(p_data_buff, addr_offset, &dtb_one_entry);
+ memset(entry_cmd, 0x0, sizeof(entry_cmd));
+ memset(entry_data, 0x0, sizeof(entry_data));
+ }
+
+ if (dtb_len == 0) {
+ rte_free(p_data_buff);
+ rte_free(p_data_buff_ex);
+ return ZXDH_RC_DTB_DOWN_LEN_INVALID;
+ }
+
+ rc = zxdh_np_dtb_write_down_table_data(dev_id,
+ queue_id,
+ dtb_len * 16,
+ p_data_buff,
+ &element_id);
+ rte_free(p_data_buff);
+ ZXDH_COMM_CHECK_RC_MEMORY_FREE_NO_ASSERT(rc,
+ "dpp_dtb_write_down_table_data", p_data_buff_ex);
+
+ rte_free(p_data_buff_ex);
+ return 0;
+}
diff --git a/drivers/net/zxdh/zxdh_np.h b/drivers/net/zxdh/zxdh_np.h
index 40961c02a2..42a652dd6b 100644
--- a/drivers/net/zxdh/zxdh_np.h
+++ b/drivers/net/zxdh/zxdh_np.h
@@ -20,6 +20,8 @@
#define ZXDH_PPU_CLUSTER_NUM (6)
#define ZXDH_PPU_INSTR_MEM_NUM (3)
#define ZXDH_SDT_CFG_LEN (2)
+#define ZXDH_SDT_H_TBL_TYPE_BT_POS (29)
+#define ZXDH_SDT_H_TBL_TYPE_BT_LEN (3)
#define ZXDH_RC_DEV_BASE (0x600)
#define ZXDH_RC_DEV_PARA_INVALID (ZXDH_RC_DEV_BASE | 0x0)
@@ -507,9 +509,16 @@ typedef struct zxdh_dtb_user_entry_t {
void *p_entry_data;
} ZXDH_DTB_USER_ENTRY_T;
+typedef struct zxdh_sdt_tbl_data_t {
+ uint32_t data_high32;
+ uint32_t data_low32;
+} ZXDH_SDT_TBL_DATA_T;
+
int zxdh_np_host_init(uint32_t dev_id, ZXDH_DEV_INIT_CTRL_T *p_dev_init_ctrl);
int zxdh_np_online_uninit(uint32_t dev_id, char *port_name, uint32_t queue_id);
int zxdh_np_dtb_table_entry_write(uint32_t dev_id, uint32_t queue_id,
uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *down_entries);
+int zxdh_np_dtb_table_entry_delete(uint32_t dev_id, uint32_t queue_id,
+ uint32_t entrynum, ZXDH_DTB_USER_ENTRY_T *delete_entries);
#endif /* ZXDH_NP_H */
diff --git a/drivers/net/zxdh/zxdh_tables.c b/drivers/net/zxdh/zxdh_tables.c
index 91376e6ec0..9fd184e612 100644
--- a/drivers/net/zxdh/zxdh_tables.c
+++ b/drivers/net/zxdh/zxdh_tables.c
@@ -11,7 +11,8 @@
#define ZXDH_SDT_VPORT_ATT_TABLE 1
#define ZXDH_SDT_PANEL_ATT_TABLE 2
-int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+int
+zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
{
int ret = 0;
@@ -70,6 +71,36 @@ zxdh_port_attr_init(struct rte_eth_dev *dev)
return ret;
};
+int
+zxdh_port_attr_uninit(struct rte_eth_dev *dev)
+{
+ struct zxdh_hw *hw = dev->data->dev_private;
+ struct zxdh_msg_info msg_info = {0};
+ struct zxdh_port_attr_table port_attr = {0};
+ int ret = 0;
+
+ if (hw->is_pf == 1) {
+ ZXDH_DTB_ERAM_ENTRY_INFO_T port_attr_entry = {hw->vfid, (uint32_t *)&port_attr};
+ ZXDH_DTB_USER_ENTRY_T entry = {
+ .sdt_no = ZXDH_SDT_VPORT_ATT_TABLE,
+ .p_entry_data = (void *)&port_attr_entry
+ };
+ ret = zxdh_np_dtb_table_entry_delete(ZXDH_DEVICE_NO, g_dtb_data.queueid, 1, &entry);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "delete port attr table failed");
+ ret = -1;
+ }
+ } else {
+ zxdh_msg_head_build(hw, ZXDH_VF_PORT_UNINIT, &msg_info);
+ ret = zxdh_vf_send_msg_to_pf(dev, &msg_info, sizeof(msg_info), NULL, 0);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "vf port tables uninit failed");
+ ret = -1;
+ }
+ }
+ return ret;
+}
+
int zxdh_panel_table_init(struct rte_eth_dev *dev)
{
struct zxdh_hw *hw = dev->data->dev_private;
diff --git a/drivers/net/zxdh/zxdh_tables.h b/drivers/net/zxdh/zxdh_tables.h
index 5d34af2f05..5e9b36faee 100644
--- a/drivers/net/zxdh/zxdh_tables.h
+++ b/drivers/net/zxdh/zxdh_tables.h
@@ -144,5 +144,6 @@ struct zxdh_panel_table {
int zxdh_port_attr_init(struct rte_eth_dev *dev);
int zxdh_panel_table_init(struct rte_eth_dev *dev);
int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
#endif /* ZXDH_TABLES_H */
--
2.27.0