Skip to contentSkip to conversation

net/zxdh: Provided zxdh basic init

PATCH In review Junlong Wang 5 participants 345 messages Sep 10, 2024 – Mar 4, 2025 Page 4 of 5

Subsystems (2)
lore
Share & tools
lore
#236 lore raw

PATCH v9 12/15 net/zxdh: vlan filter/ offload ops implementations

In reply to Junlong Wang

provided vlan filter, vlan offload ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/zxdh_ethdev.c     |  40 +++++-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 223 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   2 +
 drivers/net/zxdh/zxdh_msg.h        |  22 +++
 drivers/net/zxdh/zxdh_rxtx.c       |  18 +++
 drivers/net/zxdh/zxdh_tables.c     |  99 +++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  10 +-
 9 files changed, 417 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +3 -0
index e9b237e102..6fb006c2da 100644
@@ -16,3 +16,6 @@ Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
+VLAN offload         = Y
+QinQ offload         = Y
doc/guides/nics/zxdh.rst +3 -0
index 0399df1302..3a7585d123 100644
@@ -28,6 +28,9 @@ Features of the ZXDH PMD are:
 - Multicast MAC filter
 - Promiscuous mode
 - Multicast mode
+- VLAN filter and VLAN offload
+- VLAN stripping and inserting
+- QINQ stripping and inserting
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +39 -1
index 1dd6624e30..468f2165cb 100644
@@ -759,6 +759,34 @@ zxdh_alloc_queues(struct rte_eth_dev *dev, uint16_t nr_vq)
 	return 0;
 }
 
+static int
+zxdh_vlan_offload_configure(struct rte_eth_dev *dev)
+{
+	int ret;
+	int mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |	RTE_ETH_QINQ_STRIP_MASK;
+
+	ret = zxdh_dev_vlan_offload_set(dev, mask);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vlan offload set error");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+zxdh_dev_conf_offload(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_vlan_offload_configure(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_vlan_offload_configure failed");
+		return ret;
+	}
+
+	return 0;
+}
 
 static int32_t
 zxdh_dev_configure(struct rte_eth_dev *dev)
@@ -816,7 +844,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	nr_vq = dev->data->nb_rx_queues + dev->data->nb_tx_queues;
 	if (nr_vq == hw->queue_num)
-		return 0;
+		goto end;
 
 	PMD_DRV_LOG(DEBUG, "queue changed need reset ");
 	/* Reset the device although not necessary at startup */
@@ -848,6 +876,8 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	zxdh_pci_reinit_complete(hw);
 
+end:
+	zxdh_dev_conf_offload(dev);
 	return ret;
 }
 
@@ -1088,6 +1118,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
 	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
 	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
+	.vlan_filter_set		 = zxdh_dev_vlan_filter_set,
+	.vlan_offload_set		 = zxdh_dev_vlan_offload_set,
 };
 
 static int32_t
@@ -1346,6 +1378,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = zxdh_vlan_filter_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " vlan filter table init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev_ops.c +223 -0

238 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +2 -0
index 394ddedc0e..058d271ab3 100644
@@ -18,5 +18,7 @@ int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
 int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
+int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
+int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index 418d790a27..959fe15d23 100644
@@ -50,6 +50,8 @@
 #define ZXDH_MAC_UNFILTER          0xff
 #define ZXDH_PROMISC_MODE          1
 #define ZXDH_ALLMULTI_MODE         2
+#define ZXDH_VLAN_STRIP_MSG_TYPE   0
+#define ZXDH_QINQ_STRIP_MSG_TYPE   1
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,10 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_VLAN_FILTER_SET = 17,
+	ZXDH_VLAN_FILTER_ADD = 18,
+	ZXDH_VLAN_FILTER_DEL = 19,
+	ZXDH_VLAN_OFFLOAD = 21,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
@@ -341,6 +347,19 @@ struct __rte_packed_begin zxdh_port_promisc_msg {
 	uint8_t mc_follow;
 } __rte_packed_end;
 
+struct zxdh_vlan_filter {
+	uint16_t vlan_id;
+};
+
+struct zxdh_vlan_filter_set {
+	uint8_t enable;
+};
+
+struct __rte_packed_begin zxdh_vlan_offload {
+	uint8_t enable;
+	uint8_t type;
+} __rte_packed_end;
+
 struct __rte_packed_begin zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -363,6 +382,9 @@ struct __rte_packed_begin zxdh_msg_info {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
 		struct zxdh_port_promisc_msg port_promisc_msg;
+		struct zxdh_vlan_filter vlan_filter_msg;
+		struct zxdh_vlan_filter_set vlan_filter_set_msg;
+		struct zxdh_vlan_offload vlan_offload_msg;
 	} __rte_packed_end data;
 } __rte_packed_end;
 
drivers/net/zxdh/zxdh_rxtx.c +18 -0
index 06290d48bb..0ffce50042 100644
@@ -11,6 +11,9 @@
 #include "zxdh_pci.h"
 #include "zxdh_queue.h"
 
+#define ZXDH_SVLAN_TPID                       0x88a8
+#define ZXDH_CVLAN_TPID                       0x8100
+
 #define ZXDH_PKT_FORM_CPU                     0x20    /* 1-cpu 0-np */
 #define ZXDH_NO_IP_FRAGMENT                   0x2000  /* ip fragment flag */
 #define ZXDH_NO_IPID_UPDATE                   0x4000  /* ipid update flag */
@@ -21,6 +24,9 @@
 #define ZXDH_PI_L3TYPE_RSV                    0xC0
 #define ZXDH_PI_L3TYPE_MASK                   0xC0
 
+#define  ZXDH_PD_OFFLOAD_SVLAN_INSERT         (1 << 14)
+#define  ZXDH_PD_OFFLOAD_CVLAN_INSERT         (1 << 13)
+
 #define ZXDH_PCODE_MASK                       0x1F
 #define ZXDH_PCODE_IP_PKT_TYPE                0x01
 #define ZXDH_PCODE_TCP_PKT_TYPE               0x02
@@ -259,6 +265,18 @@ static void zxdh_xmit_fill_net_hdr(struct rte_mbuf *cookie,
 	hdr->pi_hdr.l3_offset = rte_be_to_cpu_16(l3_offset);
 	hdr->pi_hdr.l4_offset = rte_be_to_cpu_16(l3_offset + cookie->l3_len);
 
+	if (cookie->ol_flags & RTE_MBUF_F_TX_VLAN) {
+		ol_flag |= ZXDH_PD_OFFLOAD_CVLAN_INSERT;
+		hdr->pi_hdr.vlan_id = rte_be_to_cpu_16(cookie->vlan_tci);
+		hdr->pd_hdr.cvlan_insert =
+			rte_be_to_cpu_32((ZXDH_CVLAN_TPID << 16) | cookie->vlan_tci);
+	}
+	if (cookie->ol_flags & RTE_MBUF_F_TX_QINQ) {
+		ol_flag |= ZXDH_PD_OFFLOAD_SVLAN_INSERT;
+		hdr->pd_hdr.svlan_insert =
+			rte_be_to_cpu_32((ZXDH_SVLAN_TPID << 16) | cookie->vlan_tci_outer);
+	}
+
 	hdr->pd_hdr.ol_flag = rte_be_to_cpu_32(ol_flag);
 }
 
drivers/net/zxdh/zxdh_tables.c +99 -0

114 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +8 -2
index fb30c8f32e..8dac8f30dd 100644
@@ -43,7 +43,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -73,7 +73,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -194,6 +194,10 @@ struct zxdh_multicast_table {
 	uint32_t bitmap[2];
 };
 
+struct zxdh_vlan_filter_table {
+	uint32_t vlans[4];
+};
+
 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);
@@ -205,5 +209,7 @@ int zxdh_promisc_table_init(struct rte_eth_dev *dev);
 int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
 int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#237 lore raw

PATCH v9 13/15 net/zxdh: rss hash config/update, reta update/get

In reply to Junlong Wang

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  52 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 407 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  26 ++
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 603 insertions(+)
doc/guides/nics/features/zxdh.ini +3 -0
index 6fb006c2da..415ca547d0 100644
@@ -19,3 +19,6 @@ Allmulticast mode    = Y
 VLAN filter          = Y
 VLAN offload         = Y
 QinQ offload         = Y
+RSS hash             = Y
+RSS reta update      = Y
+Inner RSS            = Y
doc/guides/nics/zxdh.rst +1 -0
index 3a7585d123..3cc6a1d348 100644
@@ -31,6 +31,7 @@ Features of the ZXDH PMD are:
 - VLAN filter and VLAN offload
 - VLAN stripping and inserting
 - QINQ stripping and inserting
+- Receive Side Scaling (RSS)
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +52 -0

79 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +3 -0
index 3cdac5de73..2934fa264a 100644
@@ -82,6 +82,7 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
+	uint16_t *rss_reta;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -100,6 +101,8 @@ struct zxdh_hw {
 	uint8_t admin_status;
 	uint8_t promisc_status;
 	uint8_t allmulti_status;
+	uint8_t rss_enable;
+	uint8_t rss_init;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +407 -0

422 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +26 -0
index 058d271ab3..860716d079 100644
@@ -5,8 +5,25 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <rte_ether.h>
+
 #include "zxdh_ethdev.h"
 
+#define ZXDH_ETH_RSS_L2  RTE_ETH_RSS_L2_PAYLOAD
+#define ZXDH_ETH_RSS_IP \
+			(RTE_ETH_RSS_IPV4 | \
+			 RTE_ETH_RSS_FRAG_IPV4 | \
+			 RTE_ETH_RSS_IPV6 | \
+			 RTE_ETH_RSS_FRAG_IPV6)
+#define ZXDH_ETH_RSS_TCP    (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP)
+#define ZXDH_ETH_RSS_UDP    (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP)
+#define ZXDH_ETH_RSS_SCTP   (RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define ZXDH_HF_F5_ETH       (ZXDH_ETH_RSS_TCP | ZXDH_ETH_RSS_UDP | ZXDH_ETH_RSS_SCTP)
+#define ZXDH_HF_F3_ETH        ZXDH_ETH_RSS_IP
+#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))
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -20,5 +37,14 @@ int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+int zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size);
+int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
+			struct rte_eth_rss_reta_entry64 *reta_conf,
+			uint16_t reta_size);
+int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_configure(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index 959fe15d23..dec0a95ded 100644
@@ -182,6 +182,11 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_RSS_ENABLE = 7,
+	ZXDH_RSS_RETA_SET = 8,
+	ZXDH_RSS_RETA_GET = 9,
+	ZXDH_RSS_HF_SET = 15,
+	ZXDH_RSS_HF_GET = 16,
 	ZXDH_VLAN_FILTER_SET = 17,
 	ZXDH_VLAN_FILTER_ADD = 18,
 	ZXDH_VLAN_FILTER_DEL = 19,
@@ -302,11 +307,21 @@ struct __rte_packed_begin zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed_end;
 
+struct zxdh_rss_reta {
+	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
+};
+
+struct zxdh_rss_hf {
+	uint32_t rss_hf;
+};
+
 struct __rte_packed_begin zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
 	union __rte_packed_begin {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_rss_hf rss_hf;
+		struct zxdh_rss_reta rss_reta;
 	} __rte_packed_end;
 } __rte_packed_end;
 
@@ -360,6 +375,10 @@ struct __rte_packed_begin zxdh_vlan_offload {
 	uint8_t type;
 } __rte_packed_end;
 
+struct zxdh_rss_enable {
+	uint8_t enable;
+};
+
 struct __rte_packed_begin zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -385,6 +404,9 @@ struct __rte_packed_begin zxdh_msg_info {
 		struct zxdh_vlan_filter vlan_filter_msg;
 		struct zxdh_vlan_filter_set vlan_filter_set_msg;
 		struct zxdh_vlan_offload vlan_offload_msg;
+		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_enable rss_enable;
+		struct zxdh_rss_hf rss_hf;
 	} __rte_packed_end data;
 } __rte_packed_end;
 
drivers/net/zxdh/zxdh_tables.c +82 -0

91 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -0
index 8dac8f30dd..7bac39375c 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
 extern struct zxdh_dtb_shared_data g_dtb_data;
@@ -198,6 +199,10 @@ struct zxdh_vlan_filter_table {
 	uint32_t vlans[4];
 };
 
+struct zxdh_rss_to_vqid_table {
+	uint16_t vqm_qid[8];
+};
+
 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);
@@ -211,5 +216,7 @@ int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#238 lore raw

PATCH v9 14/15 net/zxdh: basic stats ops implementations

In reply to Junlong Wang

basic stats ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 353 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  27 +++
 drivers/net/zxdh/zxdh_msg.h        |  16 ++
 drivers/net/zxdh/zxdh_np.c         | 341 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  30 +++
 drivers/net/zxdh/zxdh_queue.h      |   2 +
 drivers/net/zxdh/zxdh_rxtx.c       |  83 ++++++-
 drivers/net/zxdh/zxdh_tables.h     |   5 +
 11 files changed, 859 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 415ca547d0..98c141cf95 100644
@@ -22,3 +22,5 @@ QinQ offload         = Y
 RSS hash             = Y
 RSS reta update      = Y
 Inner RSS            = Y
+Basic stats          = Y
+Stats per queue      = Y
doc/guides/nics/zxdh.rst +1 -0
index 3cc6a1d348..c8a52b587c 100644
@@ -32,6 +32,7 @@ Features of the ZXDH PMD are:
 - VLAN stripping and inserting
 - QINQ stripping and inserting
 - Receive Side Scaling (RSS)
+- Port hardware statistics
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index e504b239c6..636a4bb4fb 100644
@@ -1172,6 +1172,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.reta_query				 = zxdh_dev_rss_reta_query,
 	.rss_hash_update		 = zxdh_rss_hash_update,
 	.rss_hash_conf_get		 = zxdh_rss_hash_conf_get,
+	.stats_get				 = zxdh_dev_stats_get,
+	.stats_reset			 = zxdh_dev_stats_reset,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev_ops.c +353 -0

368 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +27 -0
index 860716d079..6de8ddd88c 100644
@@ -5,6 +5,8 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <stdint.h>
+
 #include <rte_ether.h>
 
 #include "zxdh_ethdev.h"
@@ -24,6 +26,29 @@
 #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))
 
+struct zxdh_hw_vqm_stats {
+	uint64_t rx_total;
+	uint64_t tx_total;
+	uint64_t rx_bytes;
+	uint64_t tx_bytes;
+	uint64_t rx_error;
+	uint64_t tx_error;
+	uint64_t rx_drop;
+};
+
+struct zxdh_hw_np_stats {
+	uint64_t np_rx_broadcast;
+	uint64_t np_tx_broadcast;
+	uint64_t np_rx_mtu_drop_pkts;
+	uint64_t np_tx_mtu_drop_pkts;
+	uint64_t np_rx_mtu_drop_bytes;
+	uint64_t np_tx_mtu_drop_bytes;
+	uint64_t np_rx_mtr_drop_pkts;
+	uint64_t np_tx_mtr_drop_pkts;
+	uint64_t np_rx_mtr_drop_bytes;
+	uint64_t np_tx_mtr_drop_bytes;
+};
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -46,5 +71,7 @@ int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
 int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 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);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +16 -0
index dec0a95ded..176073fc70 100644
@@ -9,10 +9,16 @@
 
 #include <ethdev_driver.h>
 
+#include "zxdh_ethdev_ops.h"
+
 #define ZXDH_BAR0_INDEX                 0
 #define ZXDH_CTRLCH_OFFSET              (0x2000)
 #define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
+#define ZXDH_MAC_OFFSET                 (0x24000)
+#define ZXDH_MAC_STATS_OFFSET           (0x1408)
+#define ZXDH_MAC_BYTES_OFFSET           (0xb000)
+
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
 #define ZXDH_MSIX_INTR_MSG_VEC_NUM    3
 #define ZXDH_MSIX_INTR_DTB_VEC        (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
@@ -173,7 +179,13 @@ enum pciebar_layout_type {
 
 /* riscv msg opcodes */
 enum zxdh_agent_msg_type {
+	ZXDH_MAC_STATS_GET = 10,
+	ZXDH_MAC_STATS_RESET,
 	ZXDH_MAC_LINK_GET = 14,
+	ZXDH_VQM_DEV_STATS_GET = 21,
+	ZXDH_VQM_DEV_STATS_RESET,
+	ZXDH_VQM_QUEUE_STATS_GET = 24,
+	ZXDH_VQM_QUEUE_STATS_RESET,
 };
 
 enum zxdh_msg_type {
@@ -195,6 +207,8 @@ enum zxdh_msg_type {
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
 
+	ZXDH_GET_NP_STATS = 31,
+
 	ZXDH_MSG_TYPE_END,
 };
 
@@ -319,9 +333,11 @@ struct __rte_packed_begin zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
 	union __rte_packed_begin {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
+		struct zxdh_hw_np_stats np_stats;
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_rss_hf rss_hf;
 		struct zxdh_rss_reta rss_reta;
+		struct zxdh_hw_vqm_stats vqm_stats;
 	} __rte_packed_end;
 } __rte_packed_end;
 
drivers/net/zxdh/zxdh_np.c +341 -0

356 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +30 -0
index 19d1f03f59..7da29cf7bd 100644
@@ -432,6 +432,18 @@ typedef enum zxdh_sdt_table_type_e {
 	ZXDH_SDT_TBLT_MAX     = 7,
 } ZXDH_SDT_TABLE_TYPE_E;
 
+typedef enum zxdh_dtb_dir_type_e {
+	ZXDH_DTB_DIR_DOWN_TYPE    = 0,
+	ZXDH_DTB_DIR_UP_TYPE    = 1,
+	ZXDH_DTB_DIR_TYPE_MAX,
+} ZXDH_DTB_DIR_TYPE_E;
+
+typedef enum zxdh_dtb_tab_up_user_addr_type_e {
+	ZXDH_DTB_TAB_UP_NOUSER_ADDR_TYPE     = 0,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE       = 1,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_MAX,
+} ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_E;
+
 typedef struct zxdh_dtb_lpm_entry_t {
 	uint32_t dtb_len0;
 	uint8_t *p_data_buff0;
@@ -537,6 +549,19 @@ typedef struct zxdh_dtb_hash_entry_info_t {
 	uint8_t *p_rst;
 } ZXDH_DTB_HASH_ENTRY_INFO_T;
 
+typedef struct zxdh_ppu_stat_cfg_t {
+	uint32_t eram_baddr;
+	uint32_t eram_depth;
+	uint32_t ddr_base_addr;
+	uint32_t ppu_addr_offset;
+} ZXDH_PPU_STAT_CFG_T;
+
+typedef enum zxdh_stat_cnt_mode_e {
+	ZXDH_STAT_64_MODE  = 0,
+	ZXDH_STAT_128_MODE = 1,
+	ZXDH_STAT_MAX_MODE,
+} ZXDH_STAT_CNT_MODE_E;
+
 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,
@@ -545,5 +570,10 @@ 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);
 int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
 			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
+int zxdh_np_dtb_stats_get(uint32_t dev_id,
+			uint32_t queue_id,
+			ZXDH_STAT_CNT_MODE_E rd_mode,
+			uint32_t index,
+			uint32_t *p_data);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_queue.h +2 -0
index daabb3530c..1d89703ccb 100644
@@ -53,6 +53,8 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
 #define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
 #define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
+#define ZXDH_PD_HDR_SIZE_MAX              256
+#define ZXDH_PD_HDR_SIZE_MIN              ZXDH_TYPE_HDR_SIZE
 
 /*
  * ring descriptors: 16 bytes.
drivers/net/zxdh/zxdh_rxtx.c +80 -3

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +5 -0
index 7bac39375c..c7da40f294 100644
@@ -11,6 +11,11 @@
 #define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
+#define ZXDH_MTU_STATS_EGRESS_BASE        0x8481
+#define ZXDH_MTU_STATS_INGRESS_BASE       0x8981
+#define ZXDH_BROAD_STATS_EGRESS_BASE      0xC902
+#define ZXDH_BROAD_STATS_INGRESS_BASE     0xD102
+
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 struct zxdh_port_attr_table {
Signature · 1 line
2.27.0
#239 lore raw

PATCH v9 15/15 net/zxdh: mtu update ops implementations

In reply to Junlong Wang

mtu update ops implementations.

---
 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.h     | 10 ++--
 drivers/net/zxdh/zxdh_ethdev_ops.c | 87 ++++++++++++++++++++++++++----
 drivers/net/zxdh/zxdh_ethdev_ops.h | 21 ++++----
 drivers/net/zxdh/zxdh_msg.c        | 36 ++++++-------
 drivers/net/zxdh/zxdh_msg.h        | 10 ++--
 drivers/net/zxdh/zxdh_np.c         | 34 ++++++------
 drivers/net/zxdh/zxdh_pci.c        |  4 +-
 drivers/net/zxdh/zxdh_queue.h      | 45 ++++++++--------
 drivers/net/zxdh/zxdh_rxtx.c       |  8 +--
 drivers/net/zxdh/zxdh_tables.c     | 46 +++++++++++++++-
 drivers/net/zxdh/zxdh_tables.h     |  4 ++
 15 files changed, 236 insertions(+), 109 deletions(-)
doc/guides/nics/features/zxdh.ini +1 -0
index 98c141cf95..3561e31666 100644
@@ -24,3 +24,4 @@ RSS reta update      = Y
 Inner RSS            = Y
 Basic stats          = Y
 Stats per queue      = Y
+MTU update           = Y
doc/guides/nics/zxdh.rst +2 -0
index c8a52b587c..58e0c49a2e 100644
@@ -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
drivers/net/zxdh/zxdh_common.c +2 -2
index f70c615d2f..7158bd735d 100644
@@ -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;
drivers/net/zxdh/zxdh_ethdev.c +19 -14
index 636a4bb4fb..858e3c3d47 100644
@@ -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);
@@ -256,7 +260,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) {
@@ -822,7 +826,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;
 		}
@@ -888,7 +892,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);
 
@@ -1031,13 +1035,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;
 	}
 
@@ -1064,11 +1068,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;
@@ -1135,7 +1139,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;
@@ -1174,6 +1178,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
@@ -1185,7 +1190,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;
 	}
 
@@ -1398,14 +1403,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;
 }
 
@@ -1422,7 +1427,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;
 	}
 
@@ -1434,7 +1439,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;
 	}
 
@@ -1462,7 +1467,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;
 	}
 
drivers/net/zxdh/zxdh_ethdev.h +6 -4
index 2934fa264a..fd4699c34d 100644
@@ -65,7 +65,6 @@ struct zxdh_hw {
 	struct rte_intr_handle *dtb_intr;
 	struct zxdh_virtqueue **vqs;
 	struct zxdh_chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
-	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
@@ -74,7 +73,7 @@ struct zxdh_hw {
 	uint32_t speed;
 	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
-	uint16_t *notify_base;
+	union zxdh_virport_num vport;
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
@@ -82,14 +81,16 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
-	uint16_t *rss_reta;
 
+	uint16_t *rss_reta;
+	uint16_t *notify_base;
 	uint8_t *isr;
+
 	uint8_t weak_barriers;
 	uint8_t intr_enabled;
-	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 
+	uint8_t use_msix;
 	uint8_t duplex;
 	uint8_t is_pf;
 	uint8_t msg_chan_init;
@@ -103,6 +104,7 @@ struct zxdh_hw {
 	uint8_t allmulti_status;
 	uint8_t rss_enable;
 	uint8_t rss_init;
+	uint8_t rsv[2];
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +76 -11

155 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +12 -9
index 6de8ddd88c..8dbd73e2a5 100644
@@ -26,15 +26,7 @@
 #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))
 
-struct zxdh_hw_vqm_stats {
-	uint64_t rx_total;
-	uint64_t tx_total;
-	uint64_t rx_bytes;
-	uint64_t tx_bytes;
-	uint64_t rx_error;
-	uint64_t tx_error;
-	uint64_t rx_drop;
-};
+#define ZXDH_ETHER_MIN_MTU      68
 
 struct zxdh_hw_np_stats {
 	uint64_t np_rx_broadcast;
@@ -49,6 +41,16 @@ struct zxdh_hw_np_stats {
 	uint64_t np_tx_mtr_drop_bytes;
 };
 
+struct zxdh_hw_vqm_stats {
+	uint64_t rx_total;
+	uint64_t tx_total;
+	uint64_t rx_bytes;
+	uint64_t tx_bytes;
+	uint64_t rx_error;
+	uint64_t tx_error;
+	uint64_t rx_drop;
+};
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -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 */
drivers/net/zxdh/zxdh_msg.c +18 -18
index a6e19bbdd8..9471c74fac 100644
@@ -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);
drivers/net/zxdh/zxdh_msg.h +5 -5
index 176073fc70..6f657da434 100644
@@ -321,13 +321,13 @@ struct __rte_packed_begin zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed_end;
 
-struct zxdh_rss_reta {
+struct __rte_packed_begin zxdh_rss_reta {
 	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
-};
+} __rte_packed_end;
 
-struct zxdh_rss_hf {
+struct __rte_packed_begin zxdh_rss_hf {
 	uint32_t rss_hf;
-};
+} __rte_packed_end;
 
 struct __rte_packed_begin zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
@@ -335,8 +335,8 @@ struct __rte_packed_begin zxdh_msg_reply_body {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_hw_np_stats np_stats;
 		struct zxdh_link_info_msg link_msg;
-		struct zxdh_rss_hf rss_hf;
 		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_hf rss_hf;
 		struct zxdh_hw_vqm_stats vqm_stats;
 	} __rte_packed_end;
 } __rte_packed_end;
drivers/net/zxdh/zxdh_np.c +17 -17
index 42679635f4..1e6e8f0e75 100644
@@ -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,14 +1030,14 @@ 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]"
-				"INVALID] [val1=0x%x] ! FUNCTION :%s !", __FILE__, __LINE__,
+			PMD_DRV_LOG(ERR, "ICM %s:%d[Error:VALUE[val0=0x%x]"
+				"INVALID] [val1=0x%x] FUNCTION :%s", __FILE__, __LINE__,
 				base_addr, index, __func__);
 
 			return ZXDH_PAR_CHK_INVALID_INDEX;
 		}
 		if (base_addr + index > ZXDH_SE_SMMU0_ERAM_ADDR_NUM_TOTAL - 1) {
-			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range !");
+			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range");
 			return 1;
 		}
 		temp_idx = index << 7;
@@ -1047,7 +1047,7 @@ zxdh_np_dtb_se_smmu0_ind_write(uint32_t dev_id,
 	case ZXDH_ERAM128_OPR_64b:
 	{
 		if ((base_addr + (index >> 1)) > ZXDH_SE_SMMU0_ERAM_ADDR_NUM_TOTAL - 1) {
-			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range !");
+			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range");
 			return 1;
 		}
 		temp_idx = index << 6;
@@ -1057,7 +1057,7 @@ zxdh_np_dtb_se_smmu0_ind_write(uint32_t dev_id,
 	case ZXDH_ERAM128_OPR_1b:
 	{
 		if ((base_addr + (index >> 7)) > ZXDH_SE_SMMU0_ERAM_ADDR_NUM_TOTAL - 1) {
-			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range !");
+			PMD_DRV_LOG(ERR, "dpp_se_smmu0_ind_write : index out of range");
 			return 1;
 		}
 
@@ -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;
 	}
 
drivers/net/zxdh/zxdh_pci.c +2 -2
index 6b2c4482b2..959b1b8cff 100644
@@ -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;
drivers/net/zxdh/zxdh_queue.h +24 -21

115 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.c +4 -4
index 27a61d46dd..6353d496f2 100644
@@ -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++;
drivers/net/zxdh/zxdh_tables.c +44 -2

64 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +4 -0
index c7da40f294..adedf3d0d3 100644
@@ -8,8 +8,10 @@
 #include <stdint.h>
 
 #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 */
Signature · 1 line
2.27.0
#240 lore raw

Re: [v9,00/15] net/zxdh: updated net zxdh driver

In reply to Junlong Wang

May I ask if there are any modifications needed?

If not, We hope to submit an update to the latest driver based on this version, which includes complete functionality;

We are also fully prepared for the split patch.

#241 lore raw

Re: [PATCH v9 00/15] net/zxdh: updated net zxdh driver

In reply to Junlong Wang
Quoted 77 lines · On Tue, 21 Jan 2025 11:44:18 +0800 Junlong Wang <[email protected]>…

V9:
- Remove unnecessary __rte_packed* in stats structure.

V8:
- using __rte_packed_begin/__rte_packed_end replace __rte_packed.

V7:
- resolved warning '-Waddress-of-packed-member'
in function 'zxdh_dev_rss_reta_update'.

V6:
- Remove unnecessary __rte_packed in the virtqueue structure and others.
- Remove Some blank before or after log message,
and remove some end with period in log message.

V5:
- Simplify the notify_data part in the zxdh_notify_queue function.
- Replace rte_zmalloc with rte_calloc in the rss_reta_update function.
- Remove unnecessary check in mtu_set function.

V4:
- resolved ci compile issues.

V3:
- use rte_zmalloc and rte_calloc to avoid memset.
- remove unnecessary initialization, which first usage will set.
- adjust some function which is always return 0, changed to void and skip the ASSERTION later.
- resolved some WARNING:MACRO_ARG_UNUSED issues.
- resolved some other issues.

V2:
- resolve code style and github-robot build issue.

V1:
- updated net zxdh driver
provided insert/delete/get table code funcs. provided link/mac/vlan/promiscuous/rss/mtu ops.

Junlong Wang (15):
net/zxdh: zxdh np init implementation net/zxdh: zxdh np uninit implementation net/zxdh: port tables init implementations net/zxdh: port tables unint implementations net/zxdh: rx/tx queue setup and intr enable net/zxdh: dev start/stop ops implementations net/zxdh: provided dev simple tx implementations net/zxdh: provided dev simple rx implementations net/zxdh: link info update, set link up/down net/zxdh: mac set/add/remove ops implementations net/zxdh: promisc/allmulti ops implementations net/zxdh: vlan filter/ offload ops implementations net/zxdh: rss hash config/update, reta update/get net/zxdh: basic stats ops implementations net/zxdh: mtu update ops implementations

 doc/guides/nics/features/zxdh.ini  |   18 +
 doc/guides/nics/zxdh.rst           |   17 +
 drivers/net/zxdh/meson.build       |    4 +
 drivers/net/zxdh/zxdh_common.c     |   28 +-
 drivers/net/zxdh/zxdh_common.h     |    1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  602 +++++++-
 drivers/net/zxdh/zxdh_ethdev.h     |   48 +-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 1573 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   80 ++
 drivers/net/zxdh/zxdh_msg.c        |  205 ++-
 drivers/net/zxdh/zxdh_msg.h        |  232 ++++
 drivers/net/zxdh/zxdh_np.c         | 2060 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  579 ++++++++
 drivers/net/zxdh/zxdh_pci.c        |   27 +-
 drivers/net/zxdh/zxdh_pci.h        |    9 +-
 drivers/net/zxdh/zxdh_queue.c      |  242 +++-
 drivers/net/zxdh/zxdh_queue.h      |  189 ++-
 drivers/net/zxdh/zxdh_rxtx.c       |  804 +++++++++++
 drivers/net/zxdh/zxdh_rxtx.h       |   23 +-
 drivers/net/zxdh/zxdh_tables.c     |  794 +++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  231 ++++
Quoted 9 lines
 21 files changed, 7671 insertions(+), 95 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
 create mode 100644 drivers/net/zxdh/zxdh_np.c
 create mode 100644 drivers/net/zxdh/zxdh_np.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h

Did minor conflict resolution on release notes and applied to dpdk-next-net (for-main).

#242 lore raw

PATCH v2 2/15 net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang

(np)network processor release resources in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  48 ++++
 drivers/net/zxdh/zxdh_np.c     | 494 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h     | 107 +++++++
 3 files changed, 647 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +48 -0
index c54d1f6669..b28ea4ae6f 100644
@@ -841,6 +841,51 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static void
+zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	int ret = 0;
+	int i = 0;
+
+	if (g_dtb_data.init_done && g_dtb_data.bind_device == dev) {
+		ret = zxdh_np_online_uninit(0, dev->data->name, g_dtb_data.queueid);
+		if (ret)
+			PMD_DRV_LOG(ERR, "%s dpp_np_online_uninstall failed", dev->data->name);
+
+		if (g_dtb_data.dtb_table_conf_mz)
+			rte_memzone_free(g_dtb_data.dtb_table_conf_mz);
+
+		if (g_dtb_data.dtb_table_dump_mz) {
+			rte_memzone_free(g_dtb_data.dtb_table_dump_mz);
+			g_dtb_data.dtb_table_dump_mz = NULL;
+		}
+
+		for (i = 0; i < ZXDH_MAX_BASE_DTB_TABLE_COUNT; i++) {
+			if (g_dtb_data.dtb_table_bulk_dump_mz[i]) {
+				rte_memzone_free(g_dtb_data.dtb_table_bulk_dump_mz[i]);
+				g_dtb_data.dtb_table_bulk_dump_mz[i] = NULL;
+			}
+		}
+		g_dtb_data.init_done = 0;
+		g_dtb_data.bind_device = NULL;
+	}
+	if (zxdh_shared_data != NULL)
+		zxdh_shared_data->np_init_done = 0;
+}
+
+static void
+zxdh_np_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!g_dtb_data.init_done && !g_dtb_data.dev_refcnt)
+		return;
+
+	if (--g_dtb_data.dev_refcnt == 0)
+		zxdh_np_dtb_data_res_free(hw);
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
@@ -848,6 +893,7 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	int ret = 0;
 
 	zxdh_intr_release(dev);
+	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
 
 	zxdh_dev_free_mbufs(dev);
@@ -1013,6 +1059,7 @@ zxdh_np_dtb_res_init(struct rte_eth_dev *dev)
 	return 0;
 
 free_res:
+	zxdh_np_dtb_data_res_free(hw);
 	rte_free(dpp_ctrl);
 	return ret;
 }
@@ -1181,6 +1228,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 
 err_zxdh_init:
 	zxdh_intr_release(eth_dev);
+	zxdh_np_uninit(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_np.c +492 -2

510 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +107 -0

131 lines not on this page · raw message

Signature · 1 line
2.27.0
#243 lore raw

Re: [PATCH v2 02/15] net/zxdh: zxdh np uninit implementation

Quoted 6 lines · On Tue, 10 Dec 2024 13:53:20 +0800 Junlong Wang <[email protected]>…
drivers/net/zxdh/zxdh_np.c +0 -0
index 9c50039fb1..454252cffc 100644
@@ -12,15 +12,26 @@
 #include "zxdh_logs.h"

drivers/net/zxdh/zxdh_np.c line 20

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c +4 -2
 
 static uint64_t g_np_bar_offset;
-static ZXDH_DEV_MGR_T g_dev_mgr = {0};
-static ZXDH_SDT_MGR_T g_sdt_mgr = {0};
+static ZXDH_DEV_MGR_T g_dev_mgr;
+static ZXDH_SDT_MGR_T g_sdt_mgr;
 ZXDH_PPU_CLS_BITMAP_T g_ppu_cls_bit_map[ZXDH_DEV_CHANNEL_MAX];
 ZXDH_DTB_MGR_T *p_dpp_dtb_mgr[ZXDH_DEV_CHANNEL_MAX]   = {NULL};
+ZXDH_RISCV_DTB_MGR *p_riscv_dtb_queue_mgr[ZXDH_DEV_CHANNEL_MAX] = {NULL};
+ZXDH_TLB_MGR_T *g_p_dpp_tlb_mgr[ZXDH_DEV_CHANNEL_MAX]   = {NULL}

Don't think you to initialize these to NULL since in C global variables get initialized to 0 automatically.

#244 lore raw

Re: [PATCH v2 02/15] net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang
Quoted 10 lines · On Tue, 10 Dec 2024 13:53:20 +0800 Junlong Wang <[email protected]>…
drivers/net/zxdh/zxdh_np.c +10 -0
+static uint32_t
+zxdh_np_comm_read_bits(uint8_t *p_base, uint32_t base_size_bit,
+		uint32_t *p_data, uint32_t start_bit, uint32_t end_bit)
+{
+	uint32_t   len               =  0;
+	uint32_t   start_byte_index  =  0;
+	uint32_t   end_byte_index    =  0;
+	uint32_t   byte_num          =  0;
+	uint32_t   buffer_size       =  0;
+

drivers/net/zxdh/zxdh_np.c zxdh_np_host_init(uint32_t dev_id, · line 421

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c +10 -0
+	if (0 != (base_size_bit % 8))
+		return 1;
+
+	if (start_bit > end_bit)
+		return 1;
+
+	if (base_size_bit < end_bit)
+		return 1;
+
+	len = end_bit - start_bit + 1;

Another case of the "initialize everything" style. len is set to zero when declared then first use assigns it.

#245 lore raw

Re: [PATCH v2 02/15] net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang
Quoted 14 lines · On Tue, 10 Dec 2024 13:53:20 +0800 Junlong Wang <[email protected]>…

(np)network processor release resources in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  48 ++++
 drivers/net/zxdh/zxdh_np.c     | 494 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h     | 107 +++++++
 3 files changed, 647 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +0 -0
index c54d1f6669..b28ea4ae6f 100644

drivers/net/zxdh/zxdh_ethdev.c zxdh_dev_configure(struct rte_eth_dev *dev) · line 850

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c +7 -0
@@ -841,6 +841,51 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static void
+zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	int ret = 0;
+	int i = 0;
+

Why initialize these variables (ret and i)?
They are set immediately later in the loop.

Programmers are often taught to always initialize all variables, but doing so defeats the checking in modern compilers that are able to detect variables that are used uninitialized.

#246 lore raw

PATCH v2 3/15 net/zxdh: port tables init implementations

In reply to Junlong Wang

insert port tables in host.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  23 ++
 drivers/net/zxdh/zxdh_msg.c    |  63 ++++
 drivers/net/zxdh/zxdh_msg.h    |  72 ++++
 drivers/net/zxdh/zxdh_np.c     | 662 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 210 +++++++++++
 drivers/net/zxdh/zxdh_pci.h    |   2 +
 drivers/net/zxdh/zxdh_tables.c | 104 ++++++
 drivers/net/zxdh/zxdh_tables.h | 148 ++++++++
 9 files changed, 1285 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
drivers/net/zxdh/meson.build +1 -0
index ab24a3145c..5b3af87c5b 100644
@@ -20,4 +20,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_queue.c',
         'zxdh_np.c',
+        'zxdh_tables.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +23 -0
index b28ea4ae6f..8a9ca87183 100644
@@ -14,6 +14,7 @@
 #include "zxdh_common.h"
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
+#include "zxdh_tables.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -1147,6 +1148,24 @@ zxdh_np_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_tables_init(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_port_attr_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_init failed");
+		return ret;
+	}
+
+	ret = zxdh_panel_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " panel table init failed");
+		return ret;
+	}
+	return ret;
+}
 
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
@@ -1224,6 +1243,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_tables_init(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_msg.c +63 -0

78 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +72 -0

95 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.c +662 -0

688 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +210 -0

229 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +2 -0
index d6487a574f..e3f13cb17d 100644
@@ -12,6 +12,8 @@
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_PF_PCIE_ID(pcie_id)  (((pcie_id) & 0xff00) | 1 << 11)
+
 enum zxdh_msix_status {
 	ZXDH_MSIX_NONE     = 0,
 	ZXDH_MSIX_DISABLED = 1,
drivers/net/zxdh/zxdh_tables.c new file +104 -0

104 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.27.0
#247 lore raw

Re: [PATCH v2 03/15] net/zxdh: port tables init implementations

Quoted 16 lines · On Tue, 10 Dec 2024 13:53:21 +0800 Junlong Wang <[email protected]>…

insert port tables in host.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  23 ++
 drivers/net/zxdh/zxdh_msg.c    |  63 ++++
 drivers/net/zxdh/zxdh_msg.h    |  72 ++++
 drivers/net/zxdh/zxdh_np.c     | 662 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 210 +++++++++++
 drivers/net/zxdh/zxdh_pci.h    |   2 +
 drivers/net/zxdh/zxdh_tables.c | 104 ++++++
 drivers/net/zxdh/zxdh_tables.h | 148 ++++++++
 9 files changed, 1285 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h

Is this a problem?

### [PATCH] net/zxdh: port tables init implementations

WARNING:MACRO_ARG_UNUSED: Argument 'INDEX' is not used in function-like macro #329: FILE: drivers/net/zxdh/zxdh_np.c:124:
+#define ZXDH_DTB_TAB_DOWN_PHY_ADDR_GET(DEV_ID, QUEUE_ID, INDEX) \
+ (p_dpp_dtb_mgr[(DEV_ID)]->queue_info[(QUEUE_ID)].tab_down.start_phy_addr)

total: 0 errors, 1 warnings, 0 checks, 1396 lines checked

#248 lore raw

PATCH v2 4/15 net/zxdh: port tables unint implementations

In reply to Junlong Wang

delete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  19 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 113 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  36 ++++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 177 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +19 -0
index 8a9ca87183..a72319758a 100644
@@ -887,12 +887,31 @@ 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 = 0;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+	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);
drivers/net/zxdh/zxdh_msg.h +1 -0
index 35ed5d1a1c..9997417f28 100644
@@ -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,
 } __rte_packed;
drivers/net/zxdh/zxdh_np.c +113 -0

122 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +9 -0
index 40961c02a2..42a652dd6b 100644
@@ -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 */
drivers/net/zxdh/zxdh_tables.c +34 -2
index 4284fefe3a..f0d9fab37b 100644
@@ -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,7 +71,38 @@ zxdh_port_attr_init(struct rte_eth_dev *dev)
 	return ret;
 };
 
-int zxdh_panel_table_init(struct rte_eth_dev *dev)
+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");
+			return -ret;
+		}
+	} 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");
+			return -ret;
+		}
+	}
+	return ret;
+}
+
+int
+zxdh_panel_table_init(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
 
drivers/net/zxdh/zxdh_tables.h +1 -0
index 5d34af2f05..5e9b36faee 100644
@@ -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 */
Signature · 1 line
2.27.0
#249 lore raw

Re: [PATCH v2 04/15] net/zxdh: port tables unint implementations

Quoted 106 lines · On Tue, 10 Dec 2024 13:53:22 +0800 Junlong Wang <[email protected]>…

delete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  19 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 113 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  36 ++++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 177 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +19 -0
index 8a9ca87183..a72319758a 100644
@@ -887,12 +887,31 @@ 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 = 0;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+	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);
drivers/net/zxdh/zxdh_msg.h +1 -0
index 35ed5d1a1c..9997417f28 100644
@@ -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,
 } __rte_packed;
drivers/net/zxdh/zxdh_np.c +31 -0
index 736994643d..1c1c3cbbcc 100644
@@ -24,6 +24,7 @@ ZXDH_RISCV_DTB_MGR *p_riscv_dtb_queue_mgr[ZXDH_DEV_CHANNEL_MAX] = {NULL};
 ZXDH_TLB_MGR_T *g_p_dpp_tlb_mgr[ZXDH_DEV_CHANNEL_MAX]   = {NULL};
 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_COMM_ASSERT(x)           assert(x)
 #define ZXDH_SDT_MGR_PTR_GET()    (&g_sdt_mgr)
@@ -1497,3 +1498,115 @@ 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)
+{
+	uint32_t rc = 0;
+	uint32_t entry_index = 0;
+	uint32_t sdt_no = 0;
+	uint32_t tbl_type = 0;
+	uint32_t element_id = 0xff;
+	uint32_t one_dtb_len = 0;
+	uint32_t dtb_len = 0;
+	uint32_t addr_offset = 0;
+	uint32_t max_size = 0;
+	uint8_t *p_data_buff = NULL;
+	uint8_t *p_data_buff_ex = NULL;
+	ZXDH_DTB_LPM_ENTRY_T lpm_entry = {0};

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1540

Quoted 10 lines
drivers/net/zxdh/zxdh_np.c +10 -0
+
+	uint8_t entry_cmd[ZXDH_DTB_TABLE_CMD_SIZE_BIT / 8] = {0};
+	uint8_t entry_data[ZXDH_ETCAM_WIDTH_MAX / 8] = {0};
+	ZXDH_SDT_TBL_DATA_T sdt_tbl = {0};
+	ZXDH_DTB_USER_ENTRY_T *pentry = NULL;
+	ZXDH_DTB_ENTRY_T   dtb_one_entry = {0};
+
+	ZXDH_COMM_CHECK_POINT(delete_entries);
+
+	p_data_buff = (uint8_t *)rte_malloc(NULL, ZXDH_DTB_TABLE_DATA_BUFF_SIZE, 0);

cast not needed.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1542

Quoted 2 lines
drivers/net/zxdh/zxdh_np.c +2 -0
+	ZXDH_COMM_CHECK_POINT(p_data_buff);
+	memset(p_data_buff, 0, ZXDH_DTB_TABLE_DATA_BUFF_SIZE);

If you use rte_calloc() the memset is not needed.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1545

Quoted 3 lines
drivers/net/zxdh/zxdh_np.c +3 -0
+
+	p_data_buff_ex =
+		(uint8_t *)rte_malloc(NULL, ZXDH_DTB_TABLE_DATA_BUFF_SIZE * sizeof(uint8_t), 0);

cast not needed.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1546

Quoted 1 line
drivers/net/zxdh/zxdh_np.c +1 -0
+	memset(p_data_buff_ex, 0, ZXDH_DTB_TABLE_DATA_BUFF_SIZE);

use rte_calloc instead.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1548

Quoted 2 lines
drivers/net/zxdh/zxdh_np.c +2 -0
+
+	memset((uint8_t *)&lpm_entry, 0x0, sizeof(ZXDH_DTB_LPM_ENTRY_T));

unnecessary, you already initialized this.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1550

Quoted 1 line
drivers/net/zxdh/zxdh_np.c +1 -0
+	memset((uint8_t *)&dtb_one_entry, 0x0, sizeof(ZXDH_DTB_ENTRY_T));

Also already internalized.

drivers/net/zxdh/zxdh_np.c zxdh_np_dtb_table_entry_write(uint32_t dev_id, · line 1551

Quoted 2 lines
drivers/net/zxdh/zxdh_np.c +2 -0
+	memset(entry_cmd, 0x0, sizeof(entry_cmd));
+	memset(entry_data, 0x0, sizeof(entry_data));

ditto

#250 lore raw

Re: [PATCH v2 04/15] net/zxdh: port tables unint implementations

In reply to Junlong Wang
Quoted 23 lines · On Tue, 10 Dec 2024 13:53:22 +0800 Junlong Wang <[email protected]>…

elete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  19 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 113 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  36 ++++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 177 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +3 -0
index 8a9ca87183..a72319758a 100644
@@ -887,12 +887,31 @@ 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)
+{

drivers/net/zxdh/zxdh_ethdev.c zxdh_np_uninit(struct rte_eth_dev *dev) · line 902

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c +10 -0
+	int ret = 0;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+	return ret;
+}
+

Could be simplified to:

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;
}
#251 lore raw

PATCH v2 5/15 net/zxdh: rx/tx queue setup and intr enable

In reply to Junlong Wang

rx/tx queue setup and intr enable implementations.

---
 drivers/net/zxdh/zxdh_ethdev.c |   4 +
 drivers/net/zxdh/zxdh_queue.c  | 149 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  |  33 ++++++++
 3 files changed, 186 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +4 -0
index a72319758a..9f5a9116bb 100644
@@ -934,6 +934,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.dev_configure			 = zxdh_dev_configure,
 	.dev_close				 = zxdh_dev_close,
 	.dev_infos_get			 = zxdh_dev_infos_get,
+	.rx_queue_setup			 = zxdh_dev_rx_queue_setup,
+	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
+	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_queue.c +149 -0

158 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +33 -0
index 1304d5e4ea..2f602d894f 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include <rte_common.h>
+#include <rte_atomic.h>
 
 #include "zxdh_ethdev.h"
 #include "zxdh_rxtx.h"
@@ -30,6 +31,7 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
+#define ZXDH_QUEUE_DEPTH                  1024
 
 /*
  * ring descriptors: 16 bytes.
@@ -270,8 +272,39 @@ zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
+static inline void
+zxdh_queue_enable_intr(struct zxdh_virtqueue *vq)
+{
+	if (vq->vq_packed.event_flags_shadow == ZXDH_RING_EVENT_FLAGS_DISABLE) {
+		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
+		vq->vq_packed.ring.driver->desc_event_flags = vq->vq_packed.event_flags_shadow;
+	}
+}
+
+static inline void
+zxdh_mb(uint8_t weak_barriers)
+{
+	if (weak_barriers)
+		rte_atomic_thread_fence(rte_memory_order_seq_cst);
+	else
+		rte_mb();
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
+int32_t zxdh_dev_tx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_txconf *tx_conf);
+int32_t zxdh_dev_rx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_rxconf *rx_conf,
+			struct rte_mempool *mp);
+int32_t zxdh_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
+int32_t zxdh_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 
 #endif /* ZXDH_QUEUE_H */
Signature · 1 line
2.27.0
#252 lore raw

PATCH v2 6/15 net/zxdh: dev start/stop ops implementations

In reply to Junlong Wang

dev start/stop implementations, start/stop the rx/tx queues.

---
 doc/guides/nics/features/zxdh.ini |  2 +
 doc/guides/nics/zxdh.rst          |  2 +
 drivers/net/zxdh/zxdh_ethdev.c    | 61 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c       | 24 ++++++++
 drivers/net/zxdh/zxdh_pci.h       |  1 +
 drivers/net/zxdh/zxdh_queue.c     | 91 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h     | 69 +++++++++++++++++++++++
 7 files changed, 250 insertions(+)
doc/guides/nics/features/zxdh.ini +2 -0
index 05c8091ed7..7b72be5f25 100644
@@ -7,3 +7,5 @@
 Linux                = Y
 x86-64               = Y
 ARMv8                = Y
+SR-IOV               = Y
+Multiprocess aware   = Y
doc/guides/nics/zxdh.rst +2 -0
index 2144753d75..eb970a888f 100644
@@ -18,6 +18,8 @@ Features
 Features of the ZXDH PMD are:
 
 - Multi arch support: x86_64, ARMv8.
+- Multiple queues for TX and RX
+- SR-IOV VF
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +61 -0

82 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +24 -0
index 250e67d560..83164a5c79 100644
@@ -202,6 +202,29 @@ zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 	rte_write16(0, &hw->common_cfg->queue_enable);
 }
 
+static void
+zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
+{
+	uint32_t notify_data = 0;
+
+	if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED)) {
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &
+						ZXDH_VRING_PACKED_DESC_F_AVAIL)) << 31) |
+						((uint32_t)vq->vq_avail_idx << 16) |
+						vq->vq_queue_index;
+	} else {
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
+	}
+	PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
+				 vq->vq_queue_index, notify_data, vq->notify_addr);
+	rte_write32(notify_data, vq->notify_addr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -216,6 +239,7 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_queue_num  = zxdh_set_queue_num,
 	.setup_queue    = zxdh_setup_queue,
 	.del_queue      = zxdh_del_queue,
+	.notify_queue   = zxdh_notify_queue,
 };
 
 uint8_t
drivers/net/zxdh/zxdh_pci.h +1 -0
index e3f13cb17d..5c5f72b90e 100644
@@ -144,6 +144,7 @@ struct zxdh_pci_ops {
 
 	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*notify_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
drivers/net/zxdh/zxdh_queue.c +91 -0

94 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +69 -0

92 lines not on this page · raw message

Signature · 1 line
2.27.0
#253 lore raw

Re: [PATCH v2 06/15] net/zxdh: dev start/stop ops implementations

Quoted 4 lines · On Tue, 10 Dec 2024 13:53:24 +0800 Junlong Wang <[email protected]>…

v start/stop implementations, start/stop the rx/tx queues.

---

If I re-enable the warnings for format and unaligned packed then this shows up:

../drivers/net/zxdh/zxdh_queue.c: In function ‘zxdh_dev_rx_queue_setup_finish’:
../drivers/net/zxdh/zxdh_queue.c:321:59: warning: taking address of packed member of ‘struct zxdh_virtnet_rx’ may result in an unaligned pointer value [-Waddress-of-packed-member]
321 | vq->sw_ring[vq->vq_nentries + desc_idx] = &rxvq->fake_mbuf;
| ^~~~~~~~~~~~~~~~

The problem is that the driver is using __rte_packed on structures like zxdh_virtnet_rx.

Unlike some other OS's. DPDK best practice is to only use packed where required by the hardware. Please don't use __rte_packed unless needed.

To save space, it makes sense to reorder structure members to fill holes and put hot members together for caching.

You should put fake_mbuf at the end and mark it with __rte_cache_aligned.

#254 lore raw

PATCH v2 7/15 net/zxdh: provided dev simple tx implementations

In reply to Junlong Wang

provided dev simple tx implementations.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  20 ++
 drivers/net/zxdh/zxdh_queue.h  |  26 ++-
 drivers/net/zxdh/zxdh_rxtx.c   | 396 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 5 files changed, 446 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
drivers/net/zxdh/meson.build +1 -0
index 5b3af87c5b..20b2cf484a 100644
@@ -21,4 +21,5 @@ sources = files(
         'zxdh_queue.c',
         'zxdh_np.c',
         'zxdh_tables.c',
+        'zxdh_rxtx.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +20 -0
index 8b26d56394..cbaa2de3ca 100644
@@ -15,6 +15,7 @@
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
+#include "zxdh_rxtx.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -952,6 +953,24 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t
+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);
+		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);
+		return -1;
+	}
+	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
+	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	return 0;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -967,6 +986,7 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		if (ret < 0)
 			return ret;
 	}
+	zxdh_set_rxtx_funcs(dev);
 	ret = zxdh_intr_enable(dev);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
drivers/net/zxdh/zxdh_queue.h +25 -1
index 6513aec3f0..9343df81ac 100644
@@ -21,8 +21,15 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_TQ_QUEUE_IDX                 1
 #define ZXDH_MAX_TX_INDIRECT              8
 
+/* This marks a buffer as continuing via the next field. */
+#define ZXDH_VRING_DESC_F_NEXT                 1
+
 /* This marks a buffer as write-only (otherwise read-only). */
-#define ZXDH_VRING_DESC_F_WRITE           2
+#define ZXDH_VRING_DESC_F_WRITE                2
+
+/* This means the buffer contains a list of buffer descriptors. */
+#define ZXDH_VRING_DESC_F_INDIRECT             4
+
 /* This flag means the descriptor was made available by the driver */
 #define ZXDH_VRING_PACKED_DESC_F_AVAIL   (1 << (7))
 #define ZXDH_VRING_PACKED_DESC_F_USED    (1 << (15))
@@ -35,11 +42,17 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DISABLE     0x1
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
+#define ZXDH_RING_F_INDIRECT_DESC         28
+
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
 #define ZXDH_QUEUE_DEPTH                  1024
 
 #define ZXDH_RQ_QUEUE_IDX                 0
 #define ZXDH_TQ_QUEUE_IDX                 1
+#define ZXDH_TYPE_HDR_SIZE        sizeof(struct zxdh_type_hdr)
+#define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
+#define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
+#define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
 
 /*
  * ring descriptors: 16 bytes.
@@ -355,6 +368,17 @@ static inline void zxdh_queue_notify(struct zxdh_virtqueue *vq)
 	ZXDH_VTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq);
 }
 
+static inline int32_t
+zxdh_queue_kick_prepare_packed(struct zxdh_virtqueue *vq)
+{
+	uint16_t flags = 0;
+
+	zxdh_mb(vq->hw->weak_barriers);
+	flags = vq->vq_packed.ring.device->desc_event_flags;
+
+	return (flags != ZXDH_RING_EVENT_FLAGS_DISABLE);
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
drivers/net/zxdh/zxdh_rxtx.c new file +396 -0

396 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +4 -0
index de9353b223..e07e01e821 100644
@@ -44,4 +44,8 @@ struct zxdh_virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 } __rte_packed;
 
+uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#255 lore raw

PATCH v2 8/15 net/zxdh: provided dev simple rx implementations

In reply to Junlong Wang

provided dev simple rx implementations.

---
 doc/guides/nics/features/zxdh.ini |   1 +
 doc/guides/nics/zxdh.rst          |   1 +
 drivers/net/zxdh/zxdh_ethdev.c    |   2 +
 drivers/net/zxdh/zxdh_rxtx.c      | 313 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   2 +
 5 files changed, 319 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 7b72be5f25..bb44e93fad 100644
@@ -9,3 +9,4 @@ x86-64               = Y
 ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
+Scattered Rx         = Y
doc/guides/nics/zxdh.rst +1 -0
index eb970a888f..f42db9c1f1 100644
@@ -20,6 +20,7 @@ Features of the ZXDH PMD are:
 - Multi arch support: x86_64, ARMv8.
 - Multiple queues for TX and RX
 - SR-IOV VF
+- Scattered and gather for TX and RX
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index cbaa2de3ca..acf11adb9e 100644
@@ -968,6 +968,8 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
 	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	eth_dev->rx_pkt_burst = &zxdh_recv_pkts_packed;
+
 	return 0;
 }
 
drivers/net/zxdh/zxdh_rxtx.c +313 -0

322 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +2 -0
index e07e01e821..6c1c132479 100644
@@ -47,5 +47,7 @@ struct zxdh_virtnet_tx {
 uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#256 lore raw

PATCH v2 9/15 net/zxdh: link info update, set link up/down

In reply to Junlong Wang

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  13 ++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  56 +++++++++
 drivers/net/zxdh/zxdh_msg.h        |  40 +++++++
 drivers/net/zxdh/zxdh_np.c         | 183 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  15 +++
 drivers/net/zxdh/zxdh_tables.h     |   3 +
 13 files changed, 518 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
doc/guides/nics/features/zxdh.ini +2 -0
index bb44e93fad..7da3aaced1 100644
@@ -10,3 +10,5 @@ ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
 Scattered Rx         = Y
+Link status          = Y
+Link status event    = Y
doc/guides/nics/zxdh.rst +3 -0
index f42db9c1f1..fdbc3b3923 100644
@@ -21,6 +21,9 @@ Features of the ZXDH PMD are:
 - Multiple queues for TX and RX
 - SR-IOV VF
 - Scattered and gather for TX and RX
+- Link Auto-negotiation
+- Link state information
+- Set Link down or up
 
 
 Driver compilation and testing
drivers/net/zxdh/meson.build +1 -0
index 20b2cf484a..48f8f5e1ee 100644
@@ -22,4 +22,5 @@ sources = files(
         'zxdh_np.c',
         'zxdh_tables.c',
         'zxdh_rxtx.c',
+        'zxdh_ethdev_ops.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +13 -0
index acf11adb9e..3636da2184 100644
@@ -16,6 +16,7 @@
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
 #include "zxdh_rxtx.h"
+#include "zxdh_ethdev_ops.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -105,9 +106,16 @@ static void
 zxdh_devconf_intr_handler(void *param)
 {
 	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	uint8_t isr = zxdh_pci_isr(hw);
 
 	if (zxdh_intr_unmask(dev) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
+	if (isr & ZXDH_PCI_ISR_CONFIG) {
+		if (zxdh_dev_link_update(dev, 0) == 0)
+			rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
 }
 
 
@@ -1007,6 +1015,8 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		vq = hw->vqs[logic_qidx];
 		zxdh_queue_notify(vq);
 	}
+	zxdh_dev_set_link_up(dev);
+
 	return 0;
 }
 
@@ -1021,6 +1031,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
 	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
+	.link_update			 = zxdh_dev_link_update,
+	.dev_set_link_up		 = zxdh_dev_set_link_up,
+	.dev_set_link_down		 = zxdh_dev_set_link_down,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 78b1edd5a4..ac8fd2c294 100644
@@ -69,6 +69,7 @@ struct zxdh_hw {
 	uint64_t guest_features;
 	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
 	uint16_t *notify_base;
 	uint16_t pcie_id;
@@ -90,6 +91,7 @@ struct zxdh_hw {
 	uint8_t panel_id;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
+	uint8_t admin_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c new file +166 -0

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h new file +14 -0
new file mode 100644
index 0000000000..c6d6ca56fd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_ETHDEV_OPS_H
+#define ZXDH_ETHDEV_OPS_H
+
+#include "zxdh_ethdev.h"
+
+int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
+int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
+int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+
+#endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.c +56 -0

65 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +40 -0
index 9997417f28..069e8b74d7 100644
@@ -164,11 +164,18 @@ enum pciebar_layout_type {
 	ZXDH_URI_MAX,
 };
 
+/* riscv msg opcodes */
+enum zxdh_agent_msg_type {
+	ZXDH_MAC_LINK_GET = 14,
+} __rte_packed;
+
 enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
 
+	ZXDH_PORT_ATTRS_SET = 25,
+
 	ZXDH_MSG_TYPE_END,
 } __rte_packed;
 
@@ -261,6 +268,15 @@ struct zxdh_offset_get_msg {
 	uint16_t type;
 };
 
+struct zxdh_link_info_msg {
+	uint8_t autoneg;
+	uint8_t link_state;
+	uint8_t blink_enable;
+	uint8_t duplex;
+	uint32_t speed_modes;
+	uint32_t speed;
+} __rte_packed;
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -276,6 +292,7 @@ struct zxdh_msg_reply_body {
 	enum zxdh_reps_flag flag;
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed;
 } __rte_packed;
 
@@ -291,6 +308,12 @@ struct zxdh_vf_init_msg {
 	uint8_t rss_enable;
 } __rte_packed;
 
+struct zxdh_port_attr_set_msg {
+	uint32_t mode;
+	uint32_t value;
+	uint8_t allmulti_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -298,14 +321,26 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_agent_msg_head {
+	enum zxdh_agent_msg_type msg_type;
+	uint8_t panel_id;
+	uint8_t phyport;
+	uint8_t rsv;
+	uint16_t vf_id;
+	uint16_t pcie_id;
+} __rte_packed;
+
 struct zxdh_msg_info {
 	union {
 		uint8_t head_len[ZXDH_MSG_HEAD_LEN];
 		struct zxdh_msg_head msg_head;
+		struct zxdh_agent_msg_head agent_msg_head;
 	};
 	union {
 		uint8_t datainfo[ZXDH_MSG_REQ_BODY_MAX_LEN];
 		struct zxdh_vf_init_msg vf_init_msg;
+		struct zxdh_port_attr_set_msg port_attr_msg;
+		struct zxdh_link_info_msg link_msg;
 	} __rte_packed data;
 } __rte_packed;
 
@@ -326,5 +361,10 @@ void zxdh_msg_head_build(struct zxdh_hw *hw, enum zxdh_msg_type type,
 		struct zxdh_msg_info *msg_info);
 int zxdh_vf_send_msg_to_pf(struct rte_eth_dev *dev,  void *msg_req,
 			uint16_t msg_req_len, void *reply, uint16_t reply_len);
+void zxdh_agent_msg_build(struct zxdh_hw *hw, enum zxdh_agent_msg_type type,
+		struct zxdh_msg_info *msg_info);
+int32_t zxdh_send_msg_to_riscv(struct rte_eth_dev *dev, void *msg_req,
+			uint16_t msg_req_len, void *reply, uint16_t reply_len,
+			enum ZXDH_BAR_MODULE_ID module_id);
 
 #endif /* ZXDH_MSG_H */
drivers/net/zxdh/zxdh_np.c +183 -0

192 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +20 -0
index 42a652dd6b..ac3931ba65 100644
@@ -514,11 +514,31 @@ typedef struct zxdh_sdt_tbl_data_t {
 	uint32_t data_low32;
 } ZXDH_SDT_TBL_DATA_T;
 
+typedef struct zxdh_sdt_tbl_etcam_t {
+	uint32_t table_type;
+	uint32_t etcam_id;
+	uint32_t etcam_key_mode;
+	uint32_t etcam_table_id;
+	uint32_t no_as_rsp_mode;
+	uint32_t as_en;
+	uint32_t as_eram_baddr;
+	uint32_t as_rsp_mode;
+	uint32_t etcam_table_depth;
+	uint32_t etcam_clutch_en;
+} ZXDH_SDTTBL_ETCAM_T;
+
+typedef struct zxdh_sdt_tbl_porttbl_t {
+	uint32_t table_type;
+	uint32_t porttbl_clutch_en;
+} ZXDH_SDTTBL_PORTTBL_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);
+int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
+			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +15 -0
index f0d9fab37b..d0aa8b3533 100644
@@ -11,6 +11,21 @@
 #define ZXDH_SDT_VPORT_ATT_TABLE          1
 #define ZXDH_SDT_PANEL_ATT_TABLE          2
 
+int
+zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+{
+	int ret = 0;
+
+	ZXDH_DTB_ERAM_ENTRY_INFO_T entry = {vfid, (uint32_t *)port_attr};
+	ZXDH_DTB_USER_ENTRY_T user_entry_get = {ZXDH_SDT_VPORT_ATT_TABLE, &entry};
+
+	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);
+
+	return ret;
+}
+
 int
 zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
 {
drivers/net/zxdh/zxdh_tables.h +3 -0
index 5e9b36faee..c3c852d768 100644
@@ -7,6 +7,8 @@
 
 #include <stdint.h>
 
+#define ZXDH_PORT_ATTR_IS_UP_FLAG       35
+
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 #define ZXDH_DEVICE_NO                    0
@@ -145,5 +147,6 @@ 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);
+int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#257 lore raw

Re: [PATCH v2 09/15] net/zxdh: link info update, set link up/down

Quoted 196 lines · On Tue, 10 Dec 2024 13:53:27 +0800 Junlong Wang <[email protected]>…

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  13 ++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  56 +++++++++
 drivers/net/zxdh/zxdh_msg.h        |  40 +++++++
 drivers/net/zxdh/zxdh_np.c         | 183 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  15 +++
 drivers/net/zxdh/zxdh_tables.h     |   3 +
 13 files changed, 518 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
doc/guides/nics/features/zxdh.ini +2 -0
index bb44e93fad..7da3aaced1 100644
@@ -10,3 +10,5 @@ ARMv8                = Y
 SR-IOV               = Y
 Multiprocess aware   = Y
 Scattered Rx         = Y
+Link status          = Y
+Link status event    = Y
doc/guides/nics/zxdh.rst +3 -0
index f42db9c1f1..fdbc3b3923 100644
@@ -21,6 +21,9 @@ Features of the ZXDH PMD are:
 - Multiple queues for TX and RX
 - SR-IOV VF
 - Scattered and gather for TX and RX
+- Link Auto-negotiation
+- Link state information
+- Set Link down or up
 
 
 Driver compilation and testing
drivers/net/zxdh/meson.build +1 -0
index 20b2cf484a..48f8f5e1ee 100644
@@ -22,4 +22,5 @@ sources = files(
         'zxdh_np.c',
         'zxdh_tables.c',
         'zxdh_rxtx.c',
+        'zxdh_ethdev_ops.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +13 -0
index acf11adb9e..3636da2184 100644
@@ -16,6 +16,7 @@
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
 #include "zxdh_rxtx.h"
+#include "zxdh_ethdev_ops.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -105,9 +106,16 @@ static void
 zxdh_devconf_intr_handler(void *param)
 {
 	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	uint8_t isr = zxdh_pci_isr(hw);
 
 	if (zxdh_intr_unmask(dev) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
+	if (isr & ZXDH_PCI_ISR_CONFIG) {
+		if (zxdh_dev_link_update(dev, 0) == 0)
+			rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
 }
 
 
@@ -1007,6 +1015,8 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		vq = hw->vqs[logic_qidx];
 		zxdh_queue_notify(vq);
 	}
+	zxdh_dev_set_link_up(dev);
+
 	return 0;
 }
 
@@ -1021,6 +1031,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
 	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
+	.link_update			 = zxdh_dev_link_update,
+	.dev_set_link_up		 = zxdh_dev_set_link_up,
+	.dev_set_link_down		 = zxdh_dev_set_link_down,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 78b1edd5a4..ac8fd2c294 100644
@@ -69,6 +69,7 @@ struct zxdh_hw {
 	uint64_t guest_features;
 	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
 	uint16_t *notify_base;
 	uint16_t pcie_id;
@@ -90,6 +91,7 @@ struct zxdh_hw {
 	uint8_t panel_id;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
+	uint8_t admin_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c new file +66 -0
new file mode 100644
index 0000000000..635868c4c0
@@ -0,0 +1,166 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#include "zxdh_ethdev.h"
+#include "zxdh_pci.h"
+#include "zxdh_msg.h"
+#include "zxdh_ethdev_ops.h"
+#include "zxdh_tables.h"
+#include "zxdh_logs.h"
+
+static int32_t zxdh_config_port_status(struct rte_eth_dev *dev, uint16_t link_status)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_port_attr_table port_attr = {0};
+	struct zxdh_msg_info msg_info = {0};
+	int32_t ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_get_port_attr(hw->vfid, &port_attr);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "write port_attr failed");
+			return -EAGAIN;
+		}
+		port_attr.is_up = link_status;
+
+		ret = zxdh_set_port_attr(hw->vfid, &port_attr);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "write port_attr failed");
+			return -EAGAIN;
+		}
+	} else {
+		struct zxdh_port_attr_set_msg *port_attr_msg = &msg_info.data.port_attr_msg;
+
+		zxdh_msg_head_build(hw, ZXDH_PORT_ATTRS_SET, &msg_info);
+		port_attr_msg->mode = ZXDH_PORT_ATTR_IS_UP_FLAG;
+		port_attr_msg->value = link_status;
+		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_ATTR_IS_UP_FLAG);
+			return ret;
+		}
+	}
+	return ret;
+}
+
+static int32_t
+zxdh_link_info_get(struct rte_eth_dev *dev, struct rte_eth_link *link)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	struct zxdh_msg_info msg_info = {0};
+	struct zxdh_msg_reply_info reply_info = {0};
+	uint16_t status = 0;
+	int32_t ret = 0;
+
+	if (zxdh_pci_with_feature(hw, ZXDH_NET_F_STATUS))
+		zxdh_pci_read_dev_config(hw, offsetof(struct zxdh_net_config, status),
+					&status, sizeof(status));
+
+	link->link_status = status;
+
+	if (status == RTE_ETH_LINK_DOWN) {
+		link->link_speed = RTE_ETH_SPEED_NUM_UNKNOWN;
+		link->link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
+	} else {

drivers/net/zxdh/zxdh_ethdev_ops.c line 76

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev_ops.c new file +10 -0
+		zxdh_agent_msg_build(hw, ZXDH_MAC_LINK_GET, &msg_info);
+
+		ret = zxdh_send_msg_to_riscv(dev, &msg_info, sizeof(struct zxdh_msg_info),
+				&reply_info, sizeof(struct zxdh_msg_reply_info),
+				ZXDH_BAR_MODULE_MAC);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to send msg: port 0x%x msg type %d",
+					hw->vport.vport, ZXDH_MAC_LINK_GET);
+			return -EAGAIN;
+		}

Not sure if EAGAIN is best choice here. Does send_msg return an error code already? The problem with EAGAIN is that implies that application should retry and it will then have chance to succeed.

#258 lore raw

Re: [PATCH v2 09/15] net/zxdh: link info update, set link up/down

In reply to Junlong Wang
Quoted 13 lines · On Tue, 10 Dec 2024 13:53:27 +0800 Junlong Wang <[email protected]>…

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  13 ++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  56 +++++++++
Quoted 8 lines
 drivers/net/zxdh/zxdh_msg.h        |  40 +++++++
 drivers/net/zxdh/zxdh_np.c         | 183 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  15 +++
 drivers/net/zxdh/zxdh_tables.h     |   3 +
 13 files changed, 518 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h

WARNING:MACRO_ARG_UNUSED: Argument '_uisrc_' is not used in function-like macro #486: FILE: drivers/net/zxdh/zxdh_np.c:43:
+#define ZXDH_COMM_UINT32_WRITE_BITS(_uidst_, _uisrc_, _uistartpos_, _uilen_)\
+ (((_uidst_) & ~(ZXDH_COMM_GET_BIT_MASK(uint32_t, (_uilen_)) << (_uistartpos_))))

total: 0 errors, 1 warnings, 0 checks, 664 lines checked

#259 lore raw

PATCH v2 10/15 net/zxdh: mac set/add/remove ops implementations

In reply to Junlong Wang

provided mac set/add/remove ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_common.c     |  24 +++
 drivers/net/zxdh/zxdh_common.h     |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  32 +++-
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 233 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  14 +-
 drivers/net/zxdh/zxdh_np.h         |   5 +
 drivers/net/zxdh/zxdh_tables.c     | 197 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  36 +++++
 12 files changed, 550 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 7da3aaced1..dc09fe3453 100644
@@ -12,3 +12,5 @@ Multiprocess aware   = Y
 Scattered Rx         = Y
 Link status          = Y
 Link status event    = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
doc/guides/nics/zxdh.rst +2 -0
index fdbc3b3923..e0b0776aca 100644
@@ -24,6 +24,8 @@ Features of the ZXDH PMD are:
 - Link Auto-negotiation
 - Link state information
 - Set Link down or up
+- Unicast MAC filter
+- Multicast MAC filter
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_common.c +24 -0
index 4f18c97ed7..75883a8897 100644
@@ -256,6 +256,30 @@ zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *panelid)
 	return ret;
 }
 
+static int
+zxdh_get_res_hash_id(struct zxdh_res_para *in, uint8_t *hash_id)
+{
+	uint8_t reps = 0;
+	uint16_t reps_len = 0;
+
+	if (zxdh_get_res_info(in, ZXDH_TBL_FIELD_HASHID, &reps, &reps_len) != ZXDH_BAR_MSG_OK)
+		return -1;
+
+	*hash_id = reps;
+	return ZXDH_BAR_MSG_OK;
+}
+
+int32_t
+zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx)
+{
+	struct zxdh_res_para param;
+
+	zxdh_fill_res_para(dev, &param);
+	int32_t ret = zxdh_get_res_hash_id(&param, hash_idx);
+
+	return ret;
+}
+
 uint32_t
 zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg)
 {
drivers/net/zxdh/zxdh_common.h +1 -0
index 72c29e1522..826f1fb95d 100644
@@ -22,6 +22,7 @@ struct zxdh_res_para {
 
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+int32_t zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx);
 uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
 void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
 void zxdh_release_lock(struct zxdh_hw *hw);
drivers/net/zxdh/zxdh_ethdev.c +30 -2
index 3636da2184..e9000dc59f 100644
@@ -981,6 +981,23 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_mac_config(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+	int ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_set_mac_table(hw->vport.vport,
+				&eth_dev->data->mac_addrs[0], hw->hash_search_index);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to add mac: port 0x%x", hw->vport.vport);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -1016,6 +1033,9 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		zxdh_queue_notify(vq);
 	}
 	zxdh_dev_set_link_up(dev);
+	ret = zxdh_mac_config(hw->eth_dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, " mac config failed");
 
 	return 0;
 }
@@ -1034,6 +1054,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.link_update			 = zxdh_dev_link_update,
 	.dev_set_link_up		 = zxdh_dev_set_link_up,
 	.dev_set_link_down		 = zxdh_dev_set_link_down,
+	.mac_addr_add			 = zxdh_dev_mac_addr_add,
+	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
+	.mac_addr_set			 = zxdh_dev_mac_addr_set,
 };
 
 static int32_t
@@ -1075,15 +1098,20 @@ zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
 		PMD_DRV_LOG(ERR, "Failed to get phyport");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+	PMD_DRV_LOG(DEBUG, "Get phyport success: 0x%x", hw->phyport);
 
 	hw->vfid = zxdh_vport_to_vfid(hw->vport);
 
+	if (zxdh_hashidx_get(eth_dev, &hw->hash_search_index) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get hash idx");
+		return -1;
+	}
+
 	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to get panel_id");
 		return -1;
 	}
-	PMD_DRV_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+	PMD_DRV_LOG(DEBUG, "Get panel id success: 0x%x", hw->panel_id);
 
 	return 0;
 }
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index ac8fd2c294..afdb4636ee 100644
@@ -77,6 +77,8 @@ struct zxdh_hw {
 	uint16_t port_id;
 	uint16_t vfid;
 	uint16_t queue_num;
+	uint16_t mc_num;
+	uint16_t uc_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -89,6 +91,7 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t hash_search_index;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
drivers/net/zxdh/zxdh_ethdev_ops.c +233 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index c6d6ca56fd..4630bb70db 100644
@@ -10,5 +10,9 @@
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
+		uint32_t index, uint32_t vmdq);
+int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
+void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +13 -1
index 069e8b74d7..56018103bd 100644
@@ -42,10 +42,13 @@
 #define ZXDH_MSG_REPLY_BODY_MAX_LEN  \
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - sizeof(struct zxdh_msg_reply_head))
 
-#define ZXDH_MSG_HEAD_LEN 8
+#define ZXDH_MSG_HEAD_LEN          8
 #define ZXDH_MSG_REQ_BODY_MAX_LEN  \
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - ZXDH_MSG_HEAD_LEN)
 
+#define ZXDH_MAC_FILTER            0xaa
+#define ZXDH_MAC_UNFILTER          0xff
+
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
 	ZXDH_MSG_CHAN_END_PF,
@@ -173,6 +176,8 @@ enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
+	ZXDH_MAC_ADD = 3,
+	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 
@@ -314,6 +319,12 @@ struct zxdh_port_attr_set_msg {
 	uint8_t allmulti_follow;
 } __rte_packed;
 
+struct zxdh_mac_filter {
+	uint8_t mac_flag;
+	uint8_t filter_flag;
+	struct rte_ether_addr mac;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -341,6 +352,7 @@ struct zxdh_msg_info {
 		struct zxdh_vf_init_msg vf_init_msg;
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_mac_filter mac_filter_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.h +5 -0
index ac3931ba65..19d1f03f59 100644
@@ -532,6 +532,11 @@ typedef struct zxdh_sdt_tbl_porttbl_t {
 	uint32_t porttbl_clutch_en;
 } ZXDH_SDTTBL_PORTTBL_T;
 
+typedef struct zxdh_dtb_hash_entry_info_t {
+	uint8_t *p_actu_key;
+	uint8_t *p_rst;
+} ZXDH_DTB_HASH_ENTRY_INFO_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,
drivers/net/zxdh/zxdh_tables.c +197 -0

206 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +36 -0
index c3c852d768..caa8aebdd2 100644
@@ -143,10 +143,46 @@ struct zxdh_panel_table {
 	uint32_t rsv_2;
 }; /* 16B */
 
+struct zxdh_mac_unicast_key {
+	uint16_t rsv;
+	uint8_t  dmac_addr[6];
+};
+
+struct zxdh_mac_unicast_entry {
+	uint8_t rsv1     : 7,
+			hit_flag : 1;
+	uint8_t rsv;
+	uint16_t vfid;
+};
+
+struct zxdh_mac_unicast_table {
+	struct zxdh_mac_unicast_key key;
+	struct zxdh_mac_unicast_entry entry;
+};
+
+struct zxdh_mac_multicast_key {
+	uint8_t rsv;
+	uint8_t vf_group_id;
+	uint8_t mac_addr[6];
+};
+
+struct zxdh_mac_multicast_entry {
+	uint32_t mc_pf_enable;
+	uint32_t rsv1;
+	uint32_t mc_bitmap[2];
+};
+
+struct zxdh_mac_multicast_table {
+	struct zxdh_mac_multicast_key key;
+	struct zxdh_mac_multicast_entry entry;
+};
+
 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);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
+int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#260 lore raw

PATCH v2 11/15 net/zxdh: promisc/allmulti ops implementations

In reply to Junlong Wang

provided promiscuous/allmulticast ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  18 +++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 132 +++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  10 ++
 drivers/net/zxdh/zxdh_tables.c     | 219 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  22 +++
 9 files changed, 411 insertions(+)
doc/guides/nics/features/zxdh.ini +2 -0
index dc09fe3453..e9b237e102 100644
@@ -14,3 +14,5 @@ Link status          = Y
 Link status event    = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
doc/guides/nics/zxdh.rst +2 -0
index e0b0776aca..0399df1302 100644
@@ -26,6 +26,8 @@ Features of the ZXDH PMD are:
 - Set Link down or up
 - Unicast MAC filter
 - Multicast MAC filter
+- Promiscuous mode
+- Multicast mode
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +18 -0
index e9000dc59f..a92a113f25 100644
@@ -906,6 +906,13 @@ zxdh_tables_uninit(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
 		return ret;
 	}
+
+	ret = zxdh_promisc_table_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "uninit promisc_table failed");
+		return ret;
+	}
+
 	return ret;
 }
 
@@ -1057,6 +1064,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.mac_addr_add			 = zxdh_dev_mac_addr_add,
 	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
 	.mac_addr_set			 = zxdh_dev_mac_addr_set,
+	.promiscuous_enable		 = zxdh_dev_promiscuous_enable,
+	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
+	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
+	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
 };
 
 static int32_t
@@ -1311,6 +1322,13 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, " panel table init failed");
 		return ret;
 	}
+
+	ret = zxdh_promisc_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "promisc_table_init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index afdb4636ee..1c1a4b58ce 100644
@@ -95,6 +95,8 @@ struct zxdh_hw {
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
+	uint8_t promisc_status;
+	uint8_t allmulti_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +132 -0

135 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index 4630bb70db..394ddedc0e 100644
@@ -14,5 +14,9 @@ int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_ad
 		uint32_t index, uint32_t vmdq);
 int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
+int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +10 -0
index 56018103bd..f6d54b1df7 100644
@@ -48,6 +48,8 @@
 
 #define ZXDH_MAC_FILTER            0xaa
 #define ZXDH_MAC_UNFILTER          0xff
+#define ZXDH_PROMISC_MODE          1
+#define ZXDH_ALLMULTI_MODE         2
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,7 @@ enum zxdh_msg_type {
 	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
+	ZXDH_PORT_PROMISC_SET = 26,
 
 	ZXDH_MSG_TYPE_END,
 } __rte_packed;
@@ -325,6 +328,12 @@ struct zxdh_mac_filter {
 	struct rte_ether_addr mac;
 } __rte_packed;
 
+struct zxdh_port_promisc_msg {
+	uint8_t mode;
+	uint8_t value;
+	uint8_t mc_follow;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -353,6 +362,7 @@ struct zxdh_msg_info {
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
+		struct zxdh_port_promisc_msg port_promisc_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +219 -0

232 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +22 -0
index caa8aebdd2..88cdff0053 100644
@@ -177,12 +177,34 @@ struct zxdh_mac_multicast_table {
 	struct zxdh_mac_multicast_entry entry;
 };
 
+struct zxdh_brocast_table {
+	uint32_t flag;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_unitcast_table {
+	uint32_t uc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_multicast_table {
+	uint32_t mc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
 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);
+int zxdh_promisc_table_init(struct rte_eth_dev *dev);
+int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
 int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#261 lore raw

PATCH v2 12/15 net/zxdh: vlan filter/ offload ops implementations

In reply to Junlong Wang

provided vlan filter, vlan offload ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/zxdh_ethdev.c     |  40 +++++-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 221 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   2 +
 drivers/net/zxdh/zxdh_msg.h        |  22 +++
 drivers/net/zxdh/zxdh_rxtx.c       |  18 +++
 drivers/net/zxdh/zxdh_tables.c     |  97 +++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  10 +-
 9 files changed, 413 insertions(+), 3 deletions(-)
doc/guides/nics/features/zxdh.ini +3 -0
index e9b237e102..6fb006c2da 100644
@@ -16,3 +16,6 @@ Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
+VLAN offload         = Y
+QinQ offload         = Y
doc/guides/nics/zxdh.rst +3 -0
index 0399df1302..3a7585d123 100644
@@ -28,6 +28,9 @@ Features of the ZXDH PMD are:
 - Multicast MAC filter
 - Promiscuous mode
 - Multicast mode
+- VLAN filter and VLAN offload
+- VLAN stripping and inserting
+- QINQ stripping and inserting
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +39 -1
index a92a113f25..8a8f588956 100644
@@ -759,6 +759,34 @@ zxdh_alloc_queues(struct rte_eth_dev *dev, uint16_t nr_vq)
 	return 0;
 }
 
+static int
+zxdh_vlan_offload_configure(struct rte_eth_dev *dev)
+{
+	int ret;
+	int mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |	RTE_ETH_QINQ_STRIP_MASK;
+
+	ret = zxdh_dev_vlan_offload_set(dev, mask);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vlan offload set error");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+zxdh_dev_conf_offload(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_vlan_offload_configure(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_vlan_offload_configure failed");
+		return ret;
+	}
+
+	return 0;
+}
 
 static int32_t
 zxdh_dev_configure(struct rte_eth_dev *dev)
@@ -816,7 +844,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	nr_vq = dev->data->nb_rx_queues + dev->data->nb_tx_queues;
 	if (nr_vq == hw->queue_num)
-		return 0;
+		goto end;
 
 	PMD_DRV_LOG(DEBUG, "queue changed need reset ");
 	/* Reset the device although not necessary at startup */
@@ -848,6 +876,8 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	zxdh_pci_reinit_complete(hw);
 
+end:
+	zxdh_dev_conf_offload(dev);
 	return ret;
 }
 
@@ -1068,6 +1098,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
 	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
 	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
+	.vlan_filter_set		 = zxdh_dev_vlan_filter_set,
+	.vlan_offload_set		 = zxdh_dev_vlan_offload_set,
 };
 
 static int32_t
@@ -1329,6 +1361,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = zxdh_vlan_filter_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " vlan filter table init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev_ops.c +221 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +2 -0
index 394ddedc0e..058d271ab3 100644
@@ -18,5 +18,7 @@ int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
 int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
+int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
+int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index f6d54b1df7..b1da47fc47 100644
@@ -50,6 +50,8 @@
 #define ZXDH_MAC_UNFILTER          0xff
 #define ZXDH_PROMISC_MODE          1
 #define ZXDH_ALLMULTI_MODE         2
+#define ZXDH_VLAN_STRIP_MSG_TYPE   0
+#define ZXDH_QINQ_STRIP_MSG_TYPE   1
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -180,6 +182,10 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_VLAN_FILTER_SET = 17,
+	ZXDH_VLAN_FILTER_ADD = 18,
+	ZXDH_VLAN_FILTER_DEL = 19,
+	ZXDH_VLAN_OFFLOAD = 21,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
@@ -341,6 +347,19 @@ struct zxdh_msg_head {
 	uint16_t pcieid;
 } __rte_packed;
 
+struct zxdh_vlan_filter {
+	uint16_t vlan_id;
+};
+
+struct zxdh_vlan_filter_set {
+	uint8_t enable;
+};
+
+struct zxdh_vlan_offload {
+	uint8_t enable;
+	uint8_t type;
+} __rte_packed;
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -363,6 +382,9 @@ struct zxdh_msg_info {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
 		struct zxdh_port_promisc_msg port_promisc_msg;
+		struct zxdh_vlan_filter vlan_filter_msg;
+		struct zxdh_vlan_filter_set vlan_filter_set_msg;
+		struct zxdh_vlan_offload vlan_offload_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_rxtx.c +18 -0
index 06290d48bb..0ffce50042 100644
@@ -11,6 +11,9 @@
 #include "zxdh_pci.h"
 #include "zxdh_queue.h"
 
+#define ZXDH_SVLAN_TPID                       0x88a8
+#define ZXDH_CVLAN_TPID                       0x8100
+
 #define ZXDH_PKT_FORM_CPU                     0x20    /* 1-cpu 0-np */
 #define ZXDH_NO_IP_FRAGMENT                   0x2000  /* ip fragment flag */
 #define ZXDH_NO_IPID_UPDATE                   0x4000  /* ipid update flag */
@@ -21,6 +24,9 @@
 #define ZXDH_PI_L3TYPE_RSV                    0xC0
 #define ZXDH_PI_L3TYPE_MASK                   0xC0
 
+#define  ZXDH_PD_OFFLOAD_SVLAN_INSERT         (1 << 14)
+#define  ZXDH_PD_OFFLOAD_CVLAN_INSERT         (1 << 13)
+
 #define ZXDH_PCODE_MASK                       0x1F
 #define ZXDH_PCODE_IP_PKT_TYPE                0x01
 #define ZXDH_PCODE_TCP_PKT_TYPE               0x02
@@ -259,6 +265,18 @@ static void zxdh_xmit_fill_net_hdr(struct rte_mbuf *cookie,
 	hdr->pi_hdr.l3_offset = rte_be_to_cpu_16(l3_offset);
 	hdr->pi_hdr.l4_offset = rte_be_to_cpu_16(l3_offset + cookie->l3_len);
 
+	if (cookie->ol_flags & RTE_MBUF_F_TX_VLAN) {
+		ol_flag |= ZXDH_PD_OFFLOAD_CVLAN_INSERT;
+		hdr->pi_hdr.vlan_id = rte_be_to_cpu_16(cookie->vlan_tci);
+		hdr->pd_hdr.cvlan_insert =
+			rte_be_to_cpu_32((ZXDH_CVLAN_TPID << 16) | cookie->vlan_tci);
+	}
+	if (cookie->ol_flags & RTE_MBUF_F_TX_QINQ) {
+		ol_flag |= ZXDH_PD_OFFLOAD_SVLAN_INSERT;
+		hdr->pd_hdr.svlan_insert =
+			rte_be_to_cpu_32((ZXDH_SVLAN_TPID << 16) | cookie->vlan_tci_outer);
+	}
+
 	hdr->pd_hdr.ol_flag = rte_be_to_cpu_32(ol_flag);
 }
 
drivers/net/zxdh/zxdh_tables.c +97 -0

112 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +8 -2
index 88cdff0053..3b69410a50 100644
@@ -44,7 +44,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -74,7 +74,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -195,6 +195,10 @@ struct zxdh_multicast_table {
 	uint32_t bitmap[2];
 };
 
+struct zxdh_vlan_filter_table {
+	uint32_t vlans[4];
+};
+
 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);
@@ -206,5 +210,7 @@ int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t has
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#262 lore raw

PATCH v2 13/15 net/zxdh: rss hash config/update, reta update/get

In reply to Junlong Wang

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   3 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  53 +++-
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 410 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  26 ++
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 606 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +3 -0
index 6fb006c2da..415ca547d0 100644
@@ -19,3 +19,6 @@ Allmulticast mode    = Y
 VLAN filter          = Y
 VLAN offload         = Y
 QinQ offload         = Y
+RSS hash             = Y
+RSS reta update      = Y
+Inner RSS            = Y
doc/guides/nics/zxdh.rst +1 -0
index 3a7585d123..3cc6a1d348 100644
@@ -31,6 +31,7 @@ Features of the ZXDH PMD are:
 - VLAN filter and VLAN offload
 - VLAN stripping and inserting
 - QINQ stripping and inserting
+- Receive Side Scaling (RSS)
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +52 -1

83 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +3 -0
index 1c1a4b58ce..c53c2ddeb7 100644
@@ -79,6 +79,7 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
+	uint16_t *rss_reta;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -97,6 +98,8 @@ struct zxdh_hw {
 	uint8_t admin_status;
 	uint8_t promisc_status;
 	uint8_t allmulti_status;
+	uint8_t rss_enable;
+	uint8_t rss_init;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +410 -0

425 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +26 -0
index 058d271ab3..860716d079 100644
@@ -5,8 +5,25 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <rte_ether.h>
+
 #include "zxdh_ethdev.h"
 
+#define ZXDH_ETH_RSS_L2  RTE_ETH_RSS_L2_PAYLOAD
+#define ZXDH_ETH_RSS_IP \
+			(RTE_ETH_RSS_IPV4 | \
+			 RTE_ETH_RSS_FRAG_IPV4 | \
+			 RTE_ETH_RSS_IPV6 | \
+			 RTE_ETH_RSS_FRAG_IPV6)
+#define ZXDH_ETH_RSS_TCP    (RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV6_TCP)
+#define ZXDH_ETH_RSS_UDP    (RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_NONFRAG_IPV6_UDP)
+#define ZXDH_ETH_RSS_SCTP   (RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
+#define ZXDH_HF_F5_ETH       (ZXDH_ETH_RSS_TCP | ZXDH_ETH_RSS_UDP | ZXDH_ETH_RSS_SCTP)
+#define ZXDH_HF_F3_ETH        ZXDH_ETH_RSS_IP
+#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))
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -20,5 +37,14 @@ int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+int zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size);
+int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
+			struct rte_eth_rss_reta_entry64 *reta_conf,
+			uint16_t reta_size);
+int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_configure(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index b1da47fc47..44fada3877 100644
@@ -182,6 +182,11 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_RSS_ENABLE = 7,
+	ZXDH_RSS_RETA_SET = 8,
+	ZXDH_RSS_RETA_GET = 9,
+	ZXDH_RSS_HF_SET = 15,
+	ZXDH_RSS_HF_GET = 16,
 	ZXDH_VLAN_FILTER_SET = 17,
 	ZXDH_VLAN_FILTER_ADD = 18,
 	ZXDH_VLAN_FILTER_DEL = 19,
@@ -291,6 +296,14 @@ struct zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed;
 
+struct zxdh_rss_reta {
+	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
+};
+
+struct zxdh_rss_hf {
+	uint32_t rss_hf;
+};
+
 struct zxdh_msg_reply_head {
 	uint8_t flag;
 	uint16_t reps_len;
@@ -307,6 +320,8 @@ struct zxdh_msg_reply_body {
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_rss_hf rss_hf;
+		struct zxdh_rss_reta rss_reta;
 	} __rte_packed;
 } __rte_packed;
 
@@ -360,6 +375,10 @@ struct zxdh_vlan_offload {
 	uint8_t type;
 } __rte_packed;
 
+struct zxdh_rss_enable {
+	uint8_t enable;
+};
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -385,6 +404,9 @@ struct zxdh_msg_info {
 		struct zxdh_vlan_filter vlan_filter_msg;
 		struct zxdh_vlan_filter_set vlan_filter_set_msg;
 		struct zxdh_vlan_offload vlan_offload_msg;
+		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_enable rss_enable;
+		struct zxdh_rss_hf rss_hf;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +82 -0

91 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -0
index 3b69410a50..abfe3d5b01 100644
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#define ZXDH_PORT_BASE_QID_FLAG         10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG       35
 
 extern struct zxdh_dtb_shared_data g_dtb_data;
@@ -199,6 +200,10 @@ struct zxdh_vlan_filter_table {
 	uint32_t vlans[4];
 };
 
+struct zxdh_rss_to_vqid_table {
+	uint16_t vqm_qid[8];
+};
+
 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);
@@ -212,5 +217,7 @@ int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#263 lore raw

PATCH v2 14/15 net/zxdh: basic stats ops implementations

In reply to Junlong Wang

basic stats ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 353 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  27 +++
 drivers/net/zxdh/zxdh_msg.h        |  16 ++
 drivers/net/zxdh/zxdh_np.c         | 349 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  30 +++
 drivers/net/zxdh/zxdh_queue.h      |   2 +
 drivers/net/zxdh/zxdh_rxtx.c       |  85 ++++++-
 drivers/net/zxdh/zxdh_tables.h     |   9 +-
 11 files changed, 870 insertions(+), 6 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 415ca547d0..98c141cf95 100644
@@ -22,3 +22,5 @@ QinQ offload         = Y
 RSS hash             = Y
 RSS reta update      = Y
 Inner RSS            = Y
+Basic stats          = Y
+Stats per queue      = Y
doc/guides/nics/zxdh.rst +1 -0
index 3cc6a1d348..c8a52b587c 100644
@@ -32,6 +32,7 @@ Features of the ZXDH PMD are:
 - VLAN stripping and inserting
 - QINQ stripping and inserting
 - Receive Side Scaling (RSS)
+- Port hardware statistics
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index 71c95d9bda..1238bb048d 100644
@@ -1151,6 +1151,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.reta_query				 = zxdh_dev_rss_reta_query,
 	.rss_hash_update		 = zxdh_rss_hash_update,
 	.rss_hash_conf_get		 = zxdh_rss_hash_conf_get,
+	.stats_get				 = zxdh_dev_stats_get,
+	.stats_reset			 = zxdh_dev_stats_reset,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev_ops.c +353 -0

368 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +27 -0
index 860716d079..f35378e691 100644
@@ -5,6 +5,8 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <stdint.h>
+
 #include <rte_ether.h>
 
 #include "zxdh_ethdev.h"
@@ -24,6 +26,29 @@
 #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))
 
+struct zxdh_hw_vqm_stats {
+	uint64_t rx_total;
+	uint64_t tx_total;
+	uint64_t rx_bytes;
+	uint64_t tx_bytes;
+	uint64_t rx_error;
+	uint64_t tx_error;
+	uint64_t rx_drop;
+} __rte_packed;
+
+struct zxdh_hw_np_stats {
+	uint64_t np_rx_broadcast;
+	uint64_t np_tx_broadcast;
+	uint64_t np_rx_mtu_drop_pkts;
+	uint64_t np_tx_mtu_drop_pkts;
+	uint64_t np_rx_mtu_drop_bytes;
+	uint64_t np_tx_mtu_drop_bytes;
+	uint64_t np_rx_mtr_drop_pkts;
+	uint64_t np_tx_mtr_drop_pkts;
+	uint64_t np_rx_mtr_drop_bytes;
+	uint64_t np_tx_mtr_drop_bytes;
+};
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -46,5 +71,7 @@ int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
 int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 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);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +16 -0
index 44fada3877..ced0e7e2a1 100644
@@ -9,10 +9,16 @@
 
 #include <ethdev_driver.h>
 
+#include "zxdh_ethdev_ops.h"
+
 #define ZXDH_BAR0_INDEX                 0
 #define ZXDH_CTRLCH_OFFSET              (0x2000)
 #define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
+#define ZXDH_MAC_OFFSET                 (0x24000)
+#define ZXDH_MAC_STATS_OFFSET           (0x1408)
+#define ZXDH_MAC_BYTES_OFFSET           (0xb000)
+
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
 #define ZXDH_MSIX_INTR_MSG_VEC_NUM    3
 #define ZXDH_MSIX_INTR_DTB_VEC        (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
@@ -173,7 +179,13 @@ enum pciebar_layout_type {
 
 /* riscv msg opcodes */
 enum zxdh_agent_msg_type {
+	ZXDH_MAC_STATS_GET = 10,
+	ZXDH_MAC_STATS_RESET,
 	ZXDH_MAC_LINK_GET = 14,
+	ZXDH_VQM_DEV_STATS_GET = 21,
+	ZXDH_VQM_DEV_STATS_RESET,
+	ZXDH_VQM_QUEUE_STATS_GET = 24,
+	ZXDH_VQM_QUEUE_STATS_RESET,
 } __rte_packed;
 
 enum zxdh_msg_type {
@@ -195,6 +207,8 @@ enum zxdh_msg_type {
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
 
+	ZXDH_GET_NP_STATS = 31,
+
 	ZXDH_MSG_TYPE_END,
 } __rte_packed;
 
@@ -322,6 +336,8 @@ struct zxdh_msg_reply_body {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_rss_hf rss_hf;
 		struct zxdh_rss_reta rss_reta;
+		struct zxdh_hw_vqm_stats vqm_stats;
+		struct zxdh_hw_np_stats np_stats;
 	} __rte_packed;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.c +349 -0

364 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +30 -0
index 19d1f03f59..7da29cf7bd 100644
@@ -432,6 +432,18 @@ typedef enum zxdh_sdt_table_type_e {
 	ZXDH_SDT_TBLT_MAX     = 7,
 } ZXDH_SDT_TABLE_TYPE_E;
 
+typedef enum zxdh_dtb_dir_type_e {
+	ZXDH_DTB_DIR_DOWN_TYPE    = 0,
+	ZXDH_DTB_DIR_UP_TYPE    = 1,
+	ZXDH_DTB_DIR_TYPE_MAX,
+} ZXDH_DTB_DIR_TYPE_E;
+
+typedef enum zxdh_dtb_tab_up_user_addr_type_e {
+	ZXDH_DTB_TAB_UP_NOUSER_ADDR_TYPE     = 0,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE       = 1,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_MAX,
+} ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_E;
+
 typedef struct zxdh_dtb_lpm_entry_t {
 	uint32_t dtb_len0;
 	uint8_t *p_data_buff0;
@@ -537,6 +549,19 @@ typedef struct zxdh_dtb_hash_entry_info_t {
 	uint8_t *p_rst;
 } ZXDH_DTB_HASH_ENTRY_INFO_T;
 
+typedef struct zxdh_ppu_stat_cfg_t {
+	uint32_t eram_baddr;
+	uint32_t eram_depth;
+	uint32_t ddr_base_addr;
+	uint32_t ppu_addr_offset;
+} ZXDH_PPU_STAT_CFG_T;
+
+typedef enum zxdh_stat_cnt_mode_e {
+	ZXDH_STAT_64_MODE  = 0,
+	ZXDH_STAT_128_MODE = 1,
+	ZXDH_STAT_MAX_MODE,
+} ZXDH_STAT_CNT_MODE_E;
+
 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,
@@ -545,5 +570,10 @@ 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);
 int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
 			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
+int zxdh_np_dtb_stats_get(uint32_t dev_id,
+			uint32_t queue_id,
+			ZXDH_STAT_CNT_MODE_E rd_mode,
+			uint32_t index,
+			uint32_t *p_data);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_queue.h +2 -0
index 9343df81ac..deb0dd891a 100644
@@ -53,6 +53,8 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
 #define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
 #define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
+#define ZXDH_PD_HDR_SIZE_MAX              256
+#define ZXDH_PD_HDR_SIZE_MIN              ZXDH_TYPE_HDR_SIZE
 
 /*
  * ring descriptors: 16 bytes.
drivers/net/zxdh/zxdh_rxtx.c +81 -4

167 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -2
index abfe3d5b01..e697744c23 100644
@@ -7,8 +7,13 @@
 
 #include <stdint.h>
 
-#define ZXDH_PORT_BASE_QID_FLAG         10
-#define ZXDH_PORT_ATTR_IS_UP_FLAG       35
+#define ZXDH_PORT_BASE_QID_FLAG           10
+#define ZXDH_PORT_ATTR_IS_UP_FLAG         35
+
+#define ZXDH_MTU_STATS_EGRESS_BASE        0x8481
+#define ZXDH_MTU_STATS_INGRESS_BASE       0x8981
+#define ZXDH_BROAD_STATS_EGRESS_BASE      0xC902
+#define ZXDH_BROAD_STATS_INGRESS_BASE     0xD102
 
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
Signature · 1 line
2.27.0
#264 lore raw

PATCH v2 15/15 net/zxdh: mtu update ops implementations

In reply to Junlong Wang

mtu update ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |  1 +
 doc/guides/nics/zxdh.rst           |  2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  4 ++
 drivers/net/zxdh/zxdh_ethdev_ops.c | 78 ++++++++++++++++++++++++++++++
 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, 134 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 98c141cf95..3561e31666 100644
@@ -24,3 +24,4 @@ RSS reta update      = Y
 Inner RSS            = Y
 Basic stats          = Y
 Stats per queue      = Y
+MTU update           = Y
doc/guides/nics/zxdh.rst +2 -0
index c8a52b587c..58e0c49a2e 100644
@@ -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
drivers/net/zxdh/zxdh_ethdev.c +4 -0
index 1238bb048d..72db51973d 100644
@@ -63,6 +63,9 @@ 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 |
@@ -1153,6 +1156,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
drivers/net/zxdh/zxdh_ethdev_ops.c +78 -0

87 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +3 -0
index f35378e691..fac6cbd5e8 100644
@@ -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 */
drivers/net/zxdh/zxdh_tables.c +42 -0

48 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +4 -0
index e697744c23..f7591cd948 100644
@@ -7,8 +7,10 @@
 
 #include <stdint.h>
 
+#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
@@ -224,5 +226,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 */
Signature · 1 line
2.27.0
#265 lore raw

PATCH 2/15 net/zxdh: zxdh np uninit implementation

In reply to Junlong Wang

(np)network processor release resources in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  48 ++++
 drivers/net/zxdh/zxdh_np.c     | 490 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     | 107 +++++++
 3 files changed, 645 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +48 -0
index 740e579da8..df5b8b7d55 100644
@@ -841,6 +841,51 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static void
+zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	int ret = 0;
+	int i = 0;
+
+	if (g_dtb_data.init_done && g_dtb_data.bind_device == dev) {
+		ret = zxdh_np_online_uninit(0, dev->data->name, g_dtb_data.queueid);
+		if (ret)
+			PMD_DRV_LOG(ERR, "%s dpp_np_online_uninstall failed", dev->data->name);
+
+		if (g_dtb_data.dtb_table_conf_mz)
+			rte_memzone_free(g_dtb_data.dtb_table_conf_mz);
+
+		if (g_dtb_data.dtb_table_dump_mz) {
+			rte_memzone_free(g_dtb_data.dtb_table_dump_mz);
+			g_dtb_data.dtb_table_dump_mz = NULL;
+		}
+
+		for (i = 0; i < ZXDH_MAX_BASE_DTB_TABLE_COUNT; i++) {
+			if (g_dtb_data.dtb_table_bulk_dump_mz[i]) {
+				rte_memzone_free(g_dtb_data.dtb_table_bulk_dump_mz[i]);
+				g_dtb_data.dtb_table_bulk_dump_mz[i] = NULL;
+			}
+		}
+		g_dtb_data.init_done = 0;
+		g_dtb_data.bind_device = NULL;
+	}
+	if (zxdh_shared_data != NULL)
+		zxdh_shared_data->np_init_done = 0;
+}
+
+static void
+zxdh_np_uninit(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!g_dtb_data.init_done && !g_dtb_data.dev_refcnt)
+		return;
+
+	if (--g_dtb_data.dev_refcnt == 0)
+		zxdh_np_dtb_data_res_free(hw);
+}
+
 static int
 zxdh_dev_close(struct rte_eth_dev *dev)
 {
@@ -848,6 +893,7 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	int ret = 0;
 
 	zxdh_intr_release(dev);
+	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
 
 	zxdh_dev_free_mbufs(dev);
@@ -1013,6 +1059,7 @@ zxdh_np_dtb_res_init(struct rte_eth_dev *dev)
 	return 0;
 
 free_res:
+	zxdh_np_dtb_data_res_free(hw);
 	rte_free(dpp_ctrl);
 	return ret;
 }
@@ -1179,6 +1226,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 
 err_zxdh_init:
 	zxdh_intr_release(eth_dev);
+	zxdh_np_uninit(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_np.c +490 -0

504 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +107 -0

131 lines not on this page · raw message

Signature · 1 line
2.27.0
#266 lore raw

PATCH 3/15 net/zxdh: port tables init implementations

In reply to Junlong Wang

insert port tables in host.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  24 ++
 drivers/net/zxdh/zxdh_msg.c    |  63 ++++
 drivers/net/zxdh/zxdh_msg.h    |  72 ++++
 drivers/net/zxdh/zxdh_np.c     | 666 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_np.h     | 212 ++++++++++-
 drivers/net/zxdh/zxdh_pci.h    |   2 +
 drivers/net/zxdh/zxdh_tables.c | 104 +++++
 drivers/net/zxdh/zxdh_tables.h | 148 ++++++++
 9 files changed, 1289 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_tables.c
 create mode 100644 drivers/net/zxdh/zxdh_tables.h
drivers/net/zxdh/meson.build +1 -0
index ab24a3145c..5b3af87c5b 100644
@@ -20,4 +20,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_queue.c',
         'zxdh_np.c',
+        'zxdh_tables.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +24 -0
index df5b8b7d55..9f3a5bcf9c 100644
@@ -14,6 +14,7 @@
 #include "zxdh_common.h"
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
+#include "zxdh_tables.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -1146,6 +1147,25 @@ zxdh_np_init(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_tables_init(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_port_attr_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_init failed");
+		return ret;
+	}
+
+	ret = zxdh_panel_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " panel table init failed");
+		return ret;
+	}
+	return ret;
+}
+
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -1222,6 +1242,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_tables_init(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_msg.c +63 -0

78 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +72 -0

95 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.c +664 -2

691 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +211 -1

237 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +2 -0
index d6487a574f..e3f13cb17d 100644
@@ -12,6 +12,8 @@
 
 #include "zxdh_ethdev.h"
 
+#define ZXDH_PF_PCIE_ID(pcie_id)  (((pcie_id) & 0xff00) | 1 << 11)
+
 enum zxdh_msix_status {
 	ZXDH_MSIX_NONE     = 0,
 	ZXDH_MSIX_DISABLED = 1,
drivers/net/zxdh/zxdh_tables.c new file +104 -0

104 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.27.0
#267 lore raw

PATCH 4/15 net/zxdh: port tables unint implementations

In reply to Junlong Wang

delete port tables in host.

---
 drivers/net/zxdh/zxdh_ethdev.c |  19 ++++++
 drivers/net/zxdh/zxdh_msg.h    |   1 +
 drivers/net/zxdh/zxdh_np.c     | 113 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h     |   9 +++
 drivers/net/zxdh/zxdh_tables.c |  33 +++++++++-
 drivers/net/zxdh/zxdh_tables.h |   1 +
 6 files changed, 175 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +19 -0
index 9f3a5bcf9c..63eac7781c 100644
@@ -842,6 +842,19 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+zxdh_tables_uninit(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_port_attr_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
+		return ret;
+	}
+	return ret;
+}
+
 static void
 zxdh_np_dtb_data_res_free(struct zxdh_hw *hw)
 {
@@ -893,6 +906,12 @@ 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 :unint port %s failed ", __func__, dev->device->name);
+		return -1;
+	}
+
 	zxdh_intr_release(dev);
 	zxdh_np_uninit(dev);
 	zxdh_pci_reset(hw);
drivers/net/zxdh/zxdh_msg.h +1 -0
index 35ed5d1a1c..9997417f28 100644
@@ -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,
 } __rte_packed;
drivers/net/zxdh/zxdh_np.c +113 -0

122 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +9 -0
index 02c27df887..3cb9580254 100644
@@ -54,6 +54,8 @@
 #define ZXDH_ACL_TBL_ID_MAX             (7)
 #define ZXDH_ACL_TBL_ID_NUM             (8U)
 #define ZXDH_ACL_BLOCK_NUM              (8U)
+#define ZXDH_SDT_H_TBL_TYPE_BT_POS      (29)
+#define ZXDH_SDT_H_TBL_TYPE_BT_LEN      (3)
 
 #define ZXDH_SMMU0_READ_REG_MAX_NUM              (4)
 
@@ -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 */
drivers/net/zxdh/zxdh_tables.c +32 -1
index 4284fefe3a..e28823c657 100644
@@ -70,7 +70,38 @@ zxdh_port_attr_init(struct rte_eth_dev *dev)
 	return ret;
 };
 
-int zxdh_panel_table_init(struct rte_eth_dev *dev)
+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");
+			return -ret;
+		}
+	} 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");
+			return -ret;
+		}
+	}
+	return ret;
+}
+
+int
+zxdh_panel_table_init(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
 
drivers/net/zxdh/zxdh_tables.h +1 -0
index 5d34af2f05..5e9b36faee 100644
@@ -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 */
Signature · 1 line
2.27.0
#268 lore raw

PATCH 5/15 net/zxdh: rx/tx queue setup and intr enable

In reply to Junlong Wang

rx/tx queue setup and intr enable implementations.

---
 drivers/net/zxdh/zxdh_ethdev.c |   4 +
 drivers/net/zxdh/zxdh_queue.c  | 149 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  |  33 ++++++++
 3 files changed, 186 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +4 -0
index 63eac7781c..f123e05ccf 100644
@@ -934,6 +934,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.dev_configure			 = zxdh_dev_configure,
 	.dev_close				 = zxdh_dev_close,
 	.dev_infos_get			 = zxdh_dev_infos_get,
+	.rx_queue_setup			 = zxdh_dev_rx_queue_setup,
+	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
+	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
+	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_queue.c +149 -0

158 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +33 -0
index 1304d5e4ea..2f602d894f 100644
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include <rte_common.h>
+#include <rte_atomic.h>
 
 #include "zxdh_ethdev.h"
 #include "zxdh_rxtx.h"
@@ -30,6 +31,7 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
 
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
+#define ZXDH_QUEUE_DEPTH                  1024
 
 /*
  * ring descriptors: 16 bytes.
@@ -270,8 +272,39 @@ zxdh_queue_disable_intr(struct zxdh_virtqueue *vq)
 	}
 }
 
+static inline void
+zxdh_queue_enable_intr(struct zxdh_virtqueue *vq)
+{
+	if (vq->vq_packed.event_flags_shadow == ZXDH_RING_EVENT_FLAGS_DISABLE) {
+		vq->vq_packed.event_flags_shadow = ZXDH_RING_EVENT_FLAGS_DISABLE;
+		vq->vq_packed.ring.driver->desc_event_flags = vq->vq_packed.event_flags_shadow;
+	}
+}
+
+static inline void
+zxdh_mb(uint8_t weak_barriers)
+{
+	if (weak_barriers)
+		rte_atomic_thread_fence(rte_memory_order_seq_cst);
+	else
+		rte_mb();
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
+int32_t zxdh_dev_tx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_txconf *tx_conf);
+int32_t zxdh_dev_rx_queue_setup(struct rte_eth_dev *dev,
+			uint16_t queue_idx,
+			uint16_t nb_desc,
+			uint32_t socket_id __rte_unused,
+			const struct rte_eth_rxconf *rx_conf,
+			struct rte_mempool *mp);
+int32_t zxdh_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
+int32_t zxdh_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
 
 #endif /* ZXDH_QUEUE_H */
Signature · 1 line
2.27.0
#269 lore raw

PATCH 6/15 net/zxdh: dev start/stop ops implementations

In reply to Junlong Wang

dev start/stop implementations, start/stop the rx/tx queues.

---
 doc/guides/nics/features/zxdh.ini |  2 +
 doc/guides/nics/zxdh.rst          |  2 +
 drivers/net/zxdh/zxdh_ethdev.c    | 61 ++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.c       | 24 ++++++++
 drivers/net/zxdh/zxdh_pci.h       |  1 +
 drivers/net/zxdh/zxdh_queue.c     | 93 +++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h     | 68 ++++++++++++++++++++++
 7 files changed, 251 insertions(+)
doc/guides/nics/features/zxdh.ini +2 -0
index 05c8091ed7..874541c589 100644
@@ -7,3 +7,5 @@
 Linux                = Y
 x86-64               = Y
 ARMv8                = Y
+SR-IOV               = Y
+Multiprocess         = Y
doc/guides/nics/zxdh.rst +2 -0
index 2144753d75..eb970a888f 100644
@@ -18,6 +18,8 @@ Features
 Features of the ZXDH PMD are:
 
 - Multi arch support: x86_64, ARMv8.
+- Multiple queues for TX and RX
+- SR-IOV VF
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +61 -0

82 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.c +24 -0
index 250e67d560..83164a5c79 100644
@@ -202,6 +202,29 @@ zxdh_del_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
 	rte_write16(0, &hw->common_cfg->queue_enable);
 }
 
+static void
+zxdh_notify_queue(struct zxdh_hw *hw, struct zxdh_virtqueue *vq)
+{
+	uint32_t notify_data = 0;
+
+	if (!zxdh_pci_with_feature(hw, ZXDH_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (zxdh_pci_with_feature(hw, ZXDH_F_RING_PACKED)) {
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &
+						ZXDH_VRING_PACKED_DESC_F_AVAIL)) << 31) |
+						((uint32_t)vq->vq_avail_idx << 16) |
+						vq->vq_queue_index;
+	} else {
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) | vq->vq_queue_index;
+	}
+	PMD_DRV_LOG(DEBUG, "queue:%d notify_data 0x%x notify_addr 0x%p",
+				 vq->vq_queue_index, notify_data, vq->notify_addr);
+	rte_write32(notify_data, vq->notify_addr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -216,6 +239,7 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_queue_num  = zxdh_set_queue_num,
 	.setup_queue    = zxdh_setup_queue,
 	.del_queue      = zxdh_del_queue,
+	.notify_queue   = zxdh_notify_queue,
 };
 
 uint8_t
drivers/net/zxdh/zxdh_pci.h +1 -0
index e3f13cb17d..5c5f72b90e 100644
@@ -144,6 +144,7 @@ struct zxdh_pci_ops {
 
 	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*notify_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
drivers/net/zxdh/zxdh_queue.c +93 -0

96 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +68 -0

91 lines not on this page · raw message

Signature · 1 line
2.27.0
#270 lore raw

PATCH 7/15 net/zxdh: provided dev simple tx implementations

In reply to Junlong Wang

provided dev simple tx implementations.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  20 ++
 drivers/net/zxdh/zxdh_queue.h  |  25 +++
 drivers/net/zxdh/zxdh_rxtx.c   | 395 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 5 files changed, 445 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.c
drivers/net/zxdh/meson.build +1 -0
index 5b3af87c5b..20b2cf484a 100644
@@ -21,4 +21,5 @@ sources = files(
         'zxdh_queue.c',
         'zxdh_np.c',
         'zxdh_tables.c',
+        'zxdh_rxtx.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +20 -0
index a9c0d083fe..c32de633db 100644
@@ -15,6 +15,7 @@
 #include "zxdh_queue.h"
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
+#include "zxdh_rxtx.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -952,6 +953,24 @@ zxdh_dev_close(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int32_t
+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);
+		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);
+		return -1;
+	}
+	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
+	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	return 0;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -967,6 +986,7 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		if (ret < 0)
 			return ret;
 	}
+	zxdh_set_rxtx_funcs(dev);
 	ret = zxdh_intr_enable(dev);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
drivers/net/zxdh/zxdh_queue.h +25 -0
index 343ab60c1a..1bd292e235 100644
@@ -21,6 +21,15 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_TQ_QUEUE_IDX                 1
 #define ZXDH_MAX_TX_INDIRECT              8
 
+/* This marks a buffer as continuing via the next field. */
+#define ZXDH_VRING_DESC_F_NEXT             1
+
+/* This marks a buffer as write-only (otherwise read-only). */
+#define ZXDH_VRING_DESC_F_WRITE            2
+
+/* This means the buffer contains a list of buffer descriptors. */
+#define ZXDH_VRING_DESC_F_INDIRECT         4
+
 /* This marks a buffer as write-only (otherwise read-only). */
 #define ZXDH_VRING_DESC_F_WRITE           2
 /* This flag means the descriptor was made available by the driver */
@@ -34,11 +43,16 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_RING_EVENT_FLAGS_ENABLE      0x0
 #define ZXDH_RING_EVENT_FLAGS_DISABLE     0x1
 #define ZXDH_RING_EVENT_FLAGS_DESC        0x2
+#define ZXDH_RING_F_INDIRECT_DESC         28
 
 #define ZXDH_VQ_RING_DESC_CHAIN_END       32768
 #define ZXDH_QUEUE_DEPTH                  1024
 #define ZXDH_RQ_QUEUE_IDX                 0
 #define ZXDH_TQ_QUEUE_IDX                 1
+#define ZXDH_TYPE_HDR_SIZE        sizeof(struct zxdh_type_hdr)
+#define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
+#define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
+#define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
 
 /*
  * ring descriptors: 16 bytes.
@@ -354,6 +368,17 @@ static inline void zxdh_queue_notify(struct zxdh_virtqueue *vq)
 	ZXDH_VTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq);
 }
 
+static inline int32_t
+zxdh_queue_kick_prepare_packed(struct zxdh_virtqueue *vq)
+{
+	uint16_t flags = 0;
+
+	zxdh_mb(vq->hw->weak_barriers);
+	flags = vq->vq_packed.ring.device->desc_event_flags;
+
+	return (flags != ZXDH_RING_EVENT_FLAGS_DISABLE);
+}
+
 struct rte_mbuf *zxdh_queue_detach_unused(struct zxdh_virtqueue *vq);
 int32_t zxdh_free_queues(struct rte_eth_dev *dev);
 int32_t zxdh_get_queue_type(uint16_t vtpci_queue_idx);
drivers/net/zxdh/zxdh_rxtx.c new file +395 -0

395 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +4 -0
index de9353b223..e07e01e821 100644
@@ -44,4 +44,8 @@ struct zxdh_virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 } __rte_packed;
 
+uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
+				uint16_t nb_pkts);
+
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#271 lore raw

PATCH 8/15 net/zxdh: provided dev simple rx implementations

In reply to Junlong Wang

provided dev simple rx implementations.

---
 doc/guides/nics/features/zxdh.ini |   1 +
 doc/guides/nics/zxdh.rst          |   1 +
 drivers/net/zxdh/zxdh_ethdev.c    |   2 +
 drivers/net/zxdh/zxdh_rxtx.c      | 311 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h      |   2 +
 5 files changed, 317 insertions(+)
doc/guides/nics/features/zxdh.ini +1 -0
index 874541c589..85c5c8fd32 100644
@@ -9,3 +9,4 @@ x86-64               = Y
 ARMv8                = Y
 SR-IOV               = Y
 Multiprocess         = Y
+Scattered Rx         = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +1 -0
index eb970a888f..f42db9c1f1 100644
@@ -20,6 +20,7 @@ Features of the ZXDH PMD are:
 - Multi arch support: x86_64, ARMv8.
 - Multiple queues for TX and RX
 - SR-IOV VF
+- Scattered and gather for TX and RX
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index c32de633db..226b9d6b67 100644
@@ -968,6 +968,8 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->tx_pkt_prepare = zxdh_xmit_pkts_prepare;
 	eth_dev->tx_pkt_burst = &zxdh_xmit_pkts_packed;
+	eth_dev->rx_pkt_burst = &zxdh_recv_pkts_packed;
+
 	return 0;
 }
 
drivers/net/zxdh/zxdh_rxtx.c +311 -0

320 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +2 -0
index e07e01e821..6c1c132479 100644
@@ -47,5 +47,7 @@ struct zxdh_virtnet_tx {
 uint16_t zxdh_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t zxdh_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+uint16_t zxdh_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
+				uint16_t nb_pkts);
 
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#272 lore raw

PATCH 9/15 net/zxdh: link info update, set link up/down

In reply to Junlong Wang

provided link info update, set link up /down,
and link intr.

---
 doc/guides/nics/features/zxdh.ini  |   4 +-
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/meson.build       |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  13 ++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 166 ++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  14 +++
 drivers/net/zxdh/zxdh_msg.c        |  58 ++++++++-
 drivers/net/zxdh/zxdh_msg.h        |  41 +++++++
 drivers/net/zxdh/zxdh_np.c         | 183 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  20 ++++
 drivers/net/zxdh/zxdh_tables.c     |  14 +++
 drivers/net/zxdh/zxdh_tables.h     |   2 +
 13 files changed, 519 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.c
 create mode 100644 drivers/net/zxdh/zxdh_ethdev_ops.h
doc/guides/nics/features/zxdh.ini +3 -1
index 85c5c8fd32..f052fde413 100644
@@ -9,4 +9,6 @@ x86-64               = Y
 ARMv8                = Y
 SR-IOV               = Y
 Multiprocess         = Y
-Scattered Rx         = Y
\ No newline at end of file
+Scattered Rx         = Y
+Link status          = Y
+Link status event    = Y
doc/guides/nics/zxdh.rst +3 -0
index f42db9c1f1..fdbc3b3923 100644
@@ -21,6 +21,9 @@ Features of the ZXDH PMD are:
 - Multiple queues for TX and RX
 - SR-IOV VF
 - Scattered and gather for TX and RX
+- Link Auto-negotiation
+- Link state information
+- Set Link down or up
 
 
 Driver compilation and testing
drivers/net/zxdh/meson.build +1 -0
index 20b2cf484a..48f8f5e1ee 100644
@@ -22,4 +22,5 @@ sources = files(
         'zxdh_np.c',
         'zxdh_tables.c',
         'zxdh_rxtx.c',
+        'zxdh_ethdev_ops.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +13 -0
index 226b9d6b67..57ee2f7c55 100644
@@ -16,6 +16,7 @@
 #include "zxdh_np.h"
 #include "zxdh_tables.h"
 #include "zxdh_rxtx.h"
+#include "zxdh_ethdev_ops.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 struct zxdh_shared_data *zxdh_shared_data;
@@ -105,9 +106,16 @@ static void
 zxdh_devconf_intr_handler(void *param)
 {
 	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	uint8_t isr = zxdh_pci_isr(hw);
 
 	if (zxdh_intr_unmask(dev) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
+	if (isr & ZXDH_PCI_ISR_CONFIG) {
+		if (zxdh_dev_link_update(dev, 0) == 0)
+			rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+	}
 }
 
 
@@ -1007,6 +1015,8 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		vq = hw->vqs[logic_qidx];
 		zxdh_queue_notify(vq);
 	}
+	zxdh_dev_set_link_up(dev);
+
 	return 0;
 }
 
@@ -1021,6 +1031,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.tx_queue_setup			 = zxdh_dev_tx_queue_setup,
 	.rx_queue_intr_enable	 = zxdh_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable	 = zxdh_dev_rx_queue_intr_disable,
+	.link_update			 = zxdh_dev_link_update,
+	.dev_set_link_up		 = zxdh_dev_set_link_up,
+	.dev_set_link_down		 = zxdh_dev_set_link_down,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 6fdb5fb767..cf2bc207e9 100644
@@ -70,6 +70,7 @@ struct zxdh_hw {
 	uint64_t guest_features;
 	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t speed_mode;
 	uint32_t notify_off_multiplier;
 	uint16_t *notify_base;
 	uint16_t pcie_id;
@@ -91,6 +92,7 @@ struct zxdh_hw {
 	uint8_t panel_id;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
+	uint8_t admin_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c new file +166 -0

166 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h new file +14 -0
new file mode 100644
index 0000000000..c6d6ca56fd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_ETHDEV_OPS_H
+#define ZXDH_ETHDEV_OPS_H
+
+#include "zxdh_ethdev.h"
+
+int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
+int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
+int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+
+#endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.c +57 -1

73 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +41 -0

85 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.c +183 -0

192 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +20 -0
index 3cb9580254..3a7a830d7d 100644
@@ -514,11 +514,31 @@ typedef struct zxdh_sdt_tbl_data_t {
 	uint32_t data_low32;
 } ZXDH_SDT_TBL_DATA_T;
 
+typedef struct zxdh_sdt_tbl_etcam_t {
+	uint32_t table_type;
+	uint32_t etcam_id;
+	uint32_t etcam_key_mode;
+	uint32_t etcam_table_id;
+	uint32_t no_as_rsp_mode;
+	uint32_t as_en;
+	uint32_t as_eram_baddr;
+	uint32_t as_rsp_mode;
+	uint32_t etcam_table_depth;
+	uint32_t etcam_clutch_en;
+} ZXDH_SDTTBL_ETCAM_T;
+
+typedef struct zxdh_sdt_tbl_porttbl_t {
+	uint32_t table_type;
+	uint32_t porttbl_clutch_en;
+} ZXDH_SDTTBL_PORTTBL_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);
+int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
+			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_tables.c +14 -0
index e28823c657..15098e723d 100644
@@ -26,6 +26,20 @@ int zxdh_set_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
 	return ret;
 }
 
+int zxdh_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr)
+{
+	int ret = 0;
+
+	ZXDH_DTB_ERAM_ENTRY_INFO_T entry = {vfid, (uint32_t *)port_attr};
+	ZXDH_DTB_USER_ENTRY_T user_entry_get = {ZXDH_SDT_VPORT_ATT_TABLE, &entry};
+
+	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);
+
+	return ret;
+}
+
 int
 zxdh_port_attr_init(struct rte_eth_dev *dev)
 {
drivers/net/zxdh/zxdh_tables.h +2 -0
index 5e9b36faee..7f592beb3c 100644
@@ -10,6 +10,7 @@
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
 struct zxdh_port_attr_table {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
@@ -144,6 +145,7 @@ 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_get_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 */
Signature · 1 line
2.27.0
#273 lore raw

PATCH 10/15 net/zxdh: mac set/add/remove ops implementations

In reply to Junlong Wang

provided mac set/add/remove ops.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_common.c     |  24 +++
 drivers/net/zxdh/zxdh_common.h     |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  28 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   3 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 233 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  11 ++
 drivers/net/zxdh/zxdh_np.h         |   5 +
 drivers/net/zxdh/zxdh_tables.c     | 196 ++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  36 +++++
 12 files changed, 545 insertions(+)
doc/guides/nics/features/zxdh.ini +2 -0
index f052fde413..d5f3bac917 100644
@@ -12,3 +12,5 @@ Multiprocess         = Y
 Scattered Rx         = Y
 Link status          = Y
 Link status event    = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +2 -0
index fdbc3b3923..e0b0776aca 100644
@@ -24,6 +24,8 @@ Features of the ZXDH PMD are:
 - Link Auto-negotiation
 - Link state information
 - Set Link down or up
+- Unicast MAC filter
+- Multicast MAC filter
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_common.c +24 -0
index 4f18c97ed7..75883a8897 100644
@@ -256,6 +256,30 @@ zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *panelid)
 	return ret;
 }
 
+static int
+zxdh_get_res_hash_id(struct zxdh_res_para *in, uint8_t *hash_id)
+{
+	uint8_t reps = 0;
+	uint16_t reps_len = 0;
+
+	if (zxdh_get_res_info(in, ZXDH_TBL_FIELD_HASHID, &reps, &reps_len) != ZXDH_BAR_MSG_OK)
+		return -1;
+
+	*hash_id = reps;
+	return ZXDH_BAR_MSG_OK;
+}
+
+int32_t
+zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx)
+{
+	struct zxdh_res_para param;
+
+	zxdh_fill_res_para(dev, &param);
+	int32_t ret = zxdh_get_res_hash_id(&param, hash_idx);
+
+	return ret;
+}
+
 uint32_t
 zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg)
 {
drivers/net/zxdh/zxdh_common.h +1 -0
index 72c29e1522..826f1fb95d 100644
@@ -22,6 +22,7 @@ struct zxdh_res_para {
 
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+int32_t zxdh_hashidx_get(struct rte_eth_dev *dev, uint8_t *hash_idx);
 uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
 void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
 void zxdh_release_lock(struct zxdh_hw *hw);
drivers/net/zxdh/zxdh_ethdev.c +28 -0
index 57ee2f7c55..ad3eb85676 100644
@@ -981,6 +981,23 @@ zxdh_set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+static int
+zxdh_mac_config(struct rte_eth_dev *eth_dev)
+{
+	struct zxdh_hw *hw = eth_dev->data->dev_private;
+	int ret = 0;
+
+	if (hw->is_pf) {
+		ret = zxdh_set_mac_table(hw->vport.vport,
+				&eth_dev->data->mac_addrs[0], hw->hash_search_index);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to add mac: port 0x%x", hw->vport.vport);
+			return ret;
+		}
+	}
+	return ret;
+}
+
 static int
 zxdh_dev_start(struct rte_eth_dev *dev)
 {
@@ -1016,6 +1033,9 @@ zxdh_dev_start(struct rte_eth_dev *dev)
 		zxdh_queue_notify(vq);
 	}
 	zxdh_dev_set_link_up(dev);
+	ret = zxdh_mac_config(hw->eth_dev);
+	if (ret)
+		PMD_DRV_LOG(ERR, " mac config failed");
 
 	return 0;
 }
@@ -1034,6 +1054,9 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.link_update			 = zxdh_dev_link_update,
 	.dev_set_link_up		 = zxdh_dev_set_link_up,
 	.dev_set_link_down		 = zxdh_dev_set_link_down,
+	.mac_addr_add			 = zxdh_dev_mac_addr_add,
+	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
+	.mac_addr_set			 = zxdh_dev_mac_addr_set,
 };
 
 static int32_t
@@ -1079,6 +1102,11 @@ zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
 
 	hw->vfid = zxdh_vport_to_vfid(hw->vport);
 
+	if (zxdh_hashidx_get(eth_dev, &hw->hash_search_index) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get hash idx");
+		return -1;
+	}
+
 	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
 		PMD_DRV_LOG(ERR, "Failed to get panel_id");
 		return -1;
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index cf2bc207e9..3306fdfa99 100644
@@ -78,6 +78,8 @@ struct zxdh_hw {
 	uint16_t port_id;
 	uint16_t vfid;
 	uint16_t queue_num;
+	uint16_t mc_num;
+	uint16_t uc_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -90,6 +92,7 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t hash_search_index;
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
drivers/net/zxdh/zxdh_ethdev_ops.c +233 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index c6d6ca56fd..4630bb70db 100644
@@ -10,5 +10,9 @@
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
+int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
+		uint32_t index, uint32_t vmdq);
+int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
+void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +11 -0
index 66c337443b..5b4af7d841 100644
@@ -45,6 +45,8 @@
 #define ZXDH_MSG_HEAD_LEN 8
 #define ZXDH_MSG_REQ_BODY_MAX_LEN  \
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - ZXDH_MSG_HEAD_LEN)
+#define ZXDH_MAC_FILTER            0xaa
+#define ZXDH_MAC_UNFILTER          0xff
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -173,6 +175,8 @@ enum zxdh_msg_type {
 	ZXDH_NULL = 0,
 	ZXDH_VF_PORT_INIT = 1,
 	ZXDH_VF_PORT_UNINIT = 2,
+	ZXDH_MAC_ADD = 3,
+	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 
@@ -315,6 +319,12 @@ struct zxdh_port_attr_set_msg {
 	uint8_t allmulti_follow;
 } __rte_packed;
 
+struct zxdh_mac_filter {
+	uint8_t mac_flag;
+	uint8_t filter_flag;
+	struct rte_ether_addr mac;
+} __rte_packed;
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -342,6 +352,7 @@ struct zxdh_msg_info {
 		struct zxdh_vf_init_msg vf_init_msg;
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_mac_filter mac_filter_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.h +5 -0
index 3a7a830d7d..7295b709ce 100644
@@ -509,6 +509,11 @@ typedef struct zxdh_dtb_user_entry_t {
 	void *p_entry_data;
 } ZXDH_DTB_USER_ENTRY_T;
 
+typedef struct zxdh_dtb_hash_entry_info_t {
+	uint8_t *p_actu_key;
+	uint8_t *p_rst;
+} ZXDH_DTB_HASH_ENTRY_INFO_T;
+
 typedef struct zxdh_sdt_tbl_data_t {
 	uint32_t data_high32;
 	uint32_t data_low32;
drivers/net/zxdh/zxdh_tables.c +196 -0

205 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +36 -0
index 7f592beb3c..a99eb2bec6 100644
@@ -142,10 +142,46 @@ struct zxdh_panel_table {
 	uint32_t rsv_2;
 }; /* 16B */
 
+struct zxdh_mac_unicast_key {
+	uint16_t rsv;
+	uint8_t  dmac_addr[6];
+};
+
+struct zxdh_mac_unicast_entry {
+	uint8_t rsv1     : 7,
+			hit_flag : 1;
+	uint8_t rsv;
+	uint16_t vfid;
+};
+
+struct zxdh_mac_unicast_table {
+	struct zxdh_mac_unicast_key key;
+	struct zxdh_mac_unicast_entry entry;
+};
+
+struct zxdh_mac_multicast_key {
+	uint8_t rsv;
+	uint8_t vf_group_id;
+	uint8_t mac_addr[6];
+};
+
+struct zxdh_mac_multicast_entry {
+	uint32_t mc_pf_enable;
+	uint32_t rsv1;
+	uint32_t mc_bitmap[2];
+};
+
+struct zxdh_mac_multicast_table {
+	struct zxdh_mac_multicast_key key;
+	struct zxdh_mac_multicast_entry entry;
+};
+
 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_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
+int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#274 lore raw

PATCH 11/15 net/zxdh: promiscuous/allmulticast ops implementations

In reply to Junlong Wang

provided promiscuous/allmulticast ops.

---
 doc/guides/nics/features/zxdh.ini  |   4 +-
 doc/guides/nics/zxdh.rst           |   2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  15 ++
 drivers/net/zxdh/zxdh_ethdev.h     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 132 +++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   4 +
 drivers/net/zxdh/zxdh_msg.h        |  10 ++
 drivers/net/zxdh/zxdh_tables.c     | 219 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  22 +++
 9 files changed, 409 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +3 -1
index d5f3bac917..38b715aa7c 100644
@@ -13,4 +13,6 @@ Scattered Rx         = Y
 Link status          = Y
 Link status event    = Y
 Unicast MAC filter   = Y
-Multicast MAC filter = Y
\ No newline at end of file
+Multicast MAC filter = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +2 -0
index e0b0776aca..0399df1302 100644
@@ -26,6 +26,8 @@ Features of the ZXDH PMD are:
 - Set Link down or up
 - Unicast MAC filter
 - Multicast MAC filter
+- Promiscuous mode
+- Multicast mode
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index ad3eb85676..b2c3b42176 100644
@@ -861,6 +861,11 @@ zxdh_tables_uninit(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, "zxdh_port_attr_uninit failed");
 		return ret;
 	}
+	ret = zxdh_promisc_table_uninit(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "del promisc_table failed, code:%d", ret);
+		return ret;
+	}
 	return ret;
 }
 
@@ -1057,6 +1062,10 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.mac_addr_add			 = zxdh_dev_mac_addr_add,
 	.mac_addr_remove		 = zxdh_dev_mac_addr_remove,
 	.mac_addr_set			 = zxdh_dev_mac_addr_set,
+	.promiscuous_enable		 = zxdh_dev_promiscuous_enable,
+	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
+	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
+	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
 };
 
 static int32_t
@@ -1310,6 +1319,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR, " panel table init failed");
 		return ret;
 	}
+	ret = zxdh_promisc_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "promisc_table_init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 3306fdfa99..76c5a37dfa 100644
@@ -96,6 +96,8 @@ struct zxdh_hw {
 	uint8_t has_tx_offload;
 	uint8_t has_rx_offload;
 	uint8_t admin_status;
+	uint8_t promisc_status;
+	uint8_t allmulti_status;
 };
 
 struct zxdh_dtb_shared_data {
drivers/net/zxdh/zxdh_ethdev_ops.c +132 -0

135 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +4 -0
index 4630bb70db..394ddedc0e 100644
@@ -14,5 +14,9 @@ int zxdh_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_ad
 		uint32_t index, uint32_t vmdq);
 int zxdh_dev_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 void zxdh_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
+int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
+int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
+int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +10 -0
index 5b4af7d841..002314ef19 100644
@@ -47,6 +47,8 @@
 		(ZXDH_MSG_PAYLOAD_MAX_LEN - ZXDH_MSG_HEAD_LEN)
 #define ZXDH_MAC_FILTER            0xaa
 #define ZXDH_MAC_UNFILTER          0xff
+#define ZXDH_PROMISC_MODE          1
+#define ZXDH_ALLMULTI_MODE         2
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -179,6 +181,7 @@ enum zxdh_msg_type {
 	ZXDH_MAC_DEL = 4,
 
 	ZXDH_PORT_ATTRS_SET = 25,
+	ZXDH_PORT_PROMISC_SET = 26,
 
 	ZXDH_MSG_TYPE_END,
 } __rte_packed;
@@ -325,6 +328,12 @@ struct zxdh_mac_filter {
 	struct rte_ether_addr mac;
 } __rte_packed;
 
+struct zxdh_port_promisc_msg {
+	uint8_t mode;
+	uint8_t value;
+	uint8_t mc_follow;
+} __rte_packed;
+
 struct zxdh_agent_msg_head {
 	enum zxdh_agent_msg_type msg_type;
 	uint8_t panel_id;
@@ -353,6 +362,7 @@ struct zxdh_msg_info {
 		struct zxdh_port_attr_set_msg port_attr_msg;
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
+		struct zxdh_port_promisc_msg port_promisc_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +219 -0

232 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +22 -0
index a99eb2bec6..f5767eb2ba 100644
@@ -176,12 +176,34 @@ struct zxdh_mac_multicast_table {
 	struct zxdh_mac_multicast_entry entry;
 };
 
+struct zxdh_brocast_table {
+	uint32_t flag;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_unitcast_table {
+	uint32_t uc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
+struct zxdh_multicast_table {
+	uint32_t mc_flood_pf_enable;
+	uint32_t rsv;
+	uint32_t bitmap[2];
+};
+
 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_get_port_attr(uint16_t vfid, struct zxdh_port_attr_table *port_attr);
 int zxdh_port_attr_uninit(struct rte_eth_dev *dev);
+int zxdh_promisc_table_init(struct rte_eth_dev *dev);
+int zxdh_promisc_table_uninit(struct rte_eth_dev *dev);
 int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
+int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#275 lore raw

PATCH 12/15 net/zxdh: vlan filter, vlan offload ops implementations

In reply to Junlong Wang

provided vlan filter, vlan offload ops.

---
 doc/guides/nics/features/zxdh.ini  |   4 +-
 doc/guides/nics/zxdh.rst           |   3 +
 drivers/net/zxdh/zxdh_ethdev.c     |  40 +++++-
 drivers/net/zxdh/zxdh_ethdev_ops.c | 221 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   2 +
 drivers/net/zxdh/zxdh_msg.h        |  22 +++
 drivers/net/zxdh/zxdh_rxtx.c       |  18 +++
 drivers/net/zxdh/zxdh_tables.c     |  94 ++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  10 +-
 9 files changed, 410 insertions(+), 4 deletions(-)
doc/guides/nics/features/zxdh.ini +3 -1
index 38b715aa7c..d8d0261726 100644
@@ -15,4 +15,6 @@ Link status event    = Y
 Unicast MAC filter   = Y
 Multicast MAC filter = Y
 Promiscuous mode     = Y
-Allmulticast mode    = Y
\ No newline at end of file
+Allmulticast mode    = Y
+VLAN filter          = Y
+VLAN offload         = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +3 -0
index 0399df1302..3a7585d123 100644
@@ -28,6 +28,9 @@ Features of the ZXDH PMD are:
 - Multicast MAC filter
 - Promiscuous mode
 - Multicast mode
+- VLAN filter and VLAN offload
+- VLAN stripping and inserting
+- QINQ stripping and inserting
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +39 -1
index b2c3b42176..3e6cfc1d6b 100644
@@ -759,6 +759,34 @@ zxdh_alloc_queues(struct rte_eth_dev *dev, uint16_t nr_vq)
 	return 0;
 }
 
+static int
+zxdh_vlan_offload_configure(struct rte_eth_dev *dev)
+{
+	int ret;
+	int mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |	RTE_ETH_QINQ_STRIP_MASK;
+
+	ret = zxdh_dev_vlan_offload_set(dev, mask);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "vlan offload set error");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+zxdh_dev_conf_offload(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = zxdh_vlan_offload_configure(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "zxdh_vlan_offload_configure failed");
+		return ret;
+	}
+
+	return 0;
+}
 
 static int32_t
 zxdh_dev_configure(struct rte_eth_dev *dev)
@@ -816,7 +844,7 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	nr_vq = dev->data->nb_rx_queues + dev->data->nb_tx_queues;
 	if (nr_vq == hw->queue_num)
-		return 0;
+		goto end;
 
 	PMD_DRV_LOG(DEBUG, "queue changed need reset ");
 	/* Reset the device although not necessary at startup */
@@ -848,6 +876,8 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 
 	zxdh_pci_reinit_complete(hw);
 
+end:
+	zxdh_dev_conf_offload(dev);
 	return ret;
 }
 
@@ -1066,6 +1096,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.promiscuous_disable	 = zxdh_dev_promiscuous_disable,
 	.allmulticast_enable	 = zxdh_dev_allmulticast_enable,
 	.allmulticast_disable	 = zxdh_dev_allmulticast_disable,
+	.vlan_filter_set		 = zxdh_dev_vlan_filter_set,
+	.vlan_offload_set		 = zxdh_dev_vlan_offload_set,
 };
 
 static int32_t
@@ -1325,6 +1357,12 @@ zxdh_tables_init(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = zxdh_vlan_filter_table_init(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, " panel table init failed");
+		return ret;
+	}
+
 	return ret;
 }
 
drivers/net/zxdh/zxdh_ethdev_ops.c +221 -0

236 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +2 -0
index 394ddedc0e..058d271ab3 100644
@@ -18,5 +18,7 @@ int zxdh_dev_promiscuous_enable(struct rte_eth_dev *dev);
 int zxdh_dev_promiscuous_disable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
+int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
+int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index 002314ef19..bed16d31a0 100644
@@ -49,6 +49,8 @@
 #define ZXDH_MAC_UNFILTER          0xff
 #define ZXDH_PROMISC_MODE          1
 #define ZXDH_ALLMULTI_MODE         2
+#define ZXDH_VLAN_STRIP_MSG_TYPE   0
+#define ZXDH_QINQ_STRIP_MSG_TYPE   1
 
 enum ZXDH_DRIVER_TYPE {
 	ZXDH_MSG_CHAN_END_MPF = 0,
@@ -179,6 +181,10 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_VLAN_FILTER_SET = 17,
+	ZXDH_VLAN_FILTER_ADD = 18,
+	ZXDH_VLAN_FILTER_DEL = 19,
+	ZXDH_VLAN_OFFLOAD = 21,
 
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
@@ -343,6 +349,19 @@ struct zxdh_agent_msg_head {
 	uint16_t pcie_id;
 } __rte_packed;
 
+struct zxdh_vlan_filter {
+	uint16_t vlan_id;
+};
+
+struct zxdh_vlan_filter_set {
+	uint8_t enable;
+};
+
+struct zxdh_vlan_offload {
+	uint8_t enable;
+	uint8_t type;
+} __rte_packed;
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -363,6 +382,9 @@ struct zxdh_msg_info {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_mac_filter mac_filter_msg;
 		struct zxdh_port_promisc_msg port_promisc_msg;
+		struct zxdh_vlan_filter vlan_filter_msg;
+		struct zxdh_vlan_filter_set vlan_filter_set_msg;
+		struct zxdh_vlan_offload vlan_offload_msg;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_rxtx.c +18 -0
index 07ef708112..be5865ac85 100644
@@ -11,6 +11,9 @@
 #include "zxdh_pci.h"
 #include "zxdh_queue.h"
 
+#define ZXDH_SVLAN_TPID                       0x88a8
+#define ZXDH_CVLAN_TPID                       0x8100
+
 #define ZXDH_PKT_FORM_CPU                     0x20    /* 1-cpu 0-np */
 #define ZXDH_NO_IP_FRAGMENT                   0x2000  /* ip fragment flag */
 #define ZXDH_NO_IPID_UPDATE                   0x4000  /* ipid update flag */
@@ -21,6 +24,9 @@
 #define ZXDH_PI_L3TYPE_RSV                    0xC0
 #define ZXDH_PI_L3TYPE_MASK                   0xC0
 
+#define  ZXDH_PD_OFFLOAD_SVLAN_INSERT         (1 << 14)
+#define  ZXDH_PD_OFFLOAD_CVLAN_INSERT         (1 << 13)
+
 #define ZXDH_PCODE_MASK                       0x1F
 #define ZXDH_PCODE_IP_PKT_TYPE                0x01
 #define ZXDH_PCODE_TCP_PKT_TYPE               0x02
@@ -258,6 +264,18 @@ static void zxdh_xmit_fill_net_hdr(struct rte_mbuf *cookie,
 	hdr->pi_hdr.l3_offset = rte_be_to_cpu_16(l3_offset);
 	hdr->pi_hdr.l4_offset = rte_be_to_cpu_16(l3_offset + cookie->l3_len);
 
+	if (cookie->ol_flags & RTE_MBUF_F_TX_VLAN) {
+		ol_flag |= ZXDH_PD_OFFLOAD_CVLAN_INSERT;
+		hdr->pi_hdr.vlan_id = rte_be_to_cpu_16(cookie->vlan_tci);
+		hdr->pd_hdr.cvlan_insert =
+			rte_be_to_cpu_32((ZXDH_CVLAN_TPID << 16) | cookie->vlan_tci);
+	}
+	if (cookie->ol_flags & RTE_MBUF_F_TX_QINQ) {
+		ol_flag |= ZXDH_PD_OFFLOAD_SVLAN_INSERT;
+		hdr->pd_hdr.svlan_insert =
+			rte_be_to_cpu_32((ZXDH_SVLAN_TPID << 16) | cookie->vlan_tci_outer);
+	}
+
 	hdr->pd_hdr.ol_flag = rte_be_to_cpu_32(ol_flag);
 }
 
drivers/net/zxdh/zxdh_tables.c +94 -0

109 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +8 -2
index f5767eb2ba..85e95a876f 100644
@@ -43,7 +43,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -73,7 +73,7 @@ struct zxdh_port_attr_table {
 	uint8_t rdma_offload_enable: 1;
 	uint8_t vlan_filter_enable: 1;
 	uint8_t vlan_strip_offload: 1;
-	uint8_t qinq_valn_strip_offload: 1;
+	uint8_t qinq_strip_offload: 1;
 	uint8_t rss_enable: 1;
 	uint8_t mtu_enable: 1;
 	uint8_t hit_flag: 1;
@@ -194,6 +194,10 @@ struct zxdh_multicast_table {
 	uint32_t bitmap[2];
 };
 
+struct zxdh_vlan_filter_table {
+	uint32_t vlans[4];
+};
+
 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);
@@ -205,5 +209,7 @@ int zxdh_set_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t has
 int zxdh_del_mac_table(uint16_t vport, struct rte_ether_addr *addr,  uint8_t hash_search_idx);
 int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
+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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#276 lore raw

PATCH 13/15 net/zxdh: rss hash config/update, reta update/get

In reply to Junlong Wang

provided rss hash config/update, reta update/get ops.

---
 doc/guides/nics/features/zxdh.ini  |   5 +-
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |  43 ++++
 drivers/net/zxdh/zxdh_ethdev.h     |   1 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 316 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |   8 +
 drivers/net/zxdh/zxdh_msg.h        |  22 ++
 drivers/net/zxdh/zxdh_tables.c     |  82 ++++++++
 drivers/net/zxdh/zxdh_tables.h     |   7 +
 9 files changed, 484 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +4 -1
index d8d0261726..5cae08f611 100644
@@ -17,4 +17,7 @@ Multicast MAC filter = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 VLAN filter          = Y
-VLAN offload         = Y
\ No newline at end of file
+VLAN offload         = Y
+RSS hash             = Y
+RSS reta update      = Y
+Inner RSS            = Y
doc/guides/nics/zxdh.rst +1 -0
index 3a7585d123..3cc6a1d348 100644
@@ -31,6 +31,7 @@ Features of the ZXDH PMD are:
 - VLAN filter and VLAN offload
 - VLAN stripping and inserting
 - QINQ stripping and inserting
+- Receive Side Scaling (RSS)
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +43 -0

61 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +1 -0
index 76c5a37dfa..f558a1502d 100644
@@ -80,6 +80,7 @@ struct zxdh_hw {
 	uint16_t queue_num;
 	uint16_t mc_num;
 	uint16_t uc_num;
+	uint16_t *rss_reta;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
drivers/net/zxdh/zxdh_ethdev_ops.c +316 -0

325 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +8 -0
index 058d271ab3..ef89c0d325 100644
@@ -20,5 +20,13 @@ int zxdh_dev_allmulticast_enable(struct rte_eth_dev *dev);
 int zxdh_dev_allmulticast_disable(struct rte_eth_dev *dev);
 int zxdh_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
 int zxdh_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
+int zxdh_dev_rss_reta_update(struct rte_eth_dev *dev,
+			 struct rte_eth_rss_reta_entry64 *reta_conf,
+			 uint16_t reta_size);
+int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
+			struct rte_eth_rss_reta_entry64 *reta_conf,
+			uint16_t reta_size);
+int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +22 -0
index bed16d31a0..57092abe92 100644
@@ -181,6 +181,11 @@ enum zxdh_msg_type {
 	ZXDH_VF_PORT_UNINIT = 2,
 	ZXDH_MAC_ADD = 3,
 	ZXDH_MAC_DEL = 4,
+	ZXDH_RSS_ENABLE = 7,
+	ZXDH_RSS_RETA_SET = 8,
+	ZXDH_RSS_RETA_GET = 9,
+	ZXDH_RSS_HF_SET = 15,
+	ZXDH_RSS_HF_GET = 16,
 	ZXDH_VLAN_FILTER_SET = 17,
 	ZXDH_VLAN_FILTER_ADD = 18,
 	ZXDH_VLAN_FILTER_DEL = 19,
@@ -290,6 +295,14 @@ struct zxdh_link_info_msg {
 	uint32_t speed;
 } __rte_packed;
 
+struct zxdh_rss_reta {
+	uint32_t reta[RTE_ETH_RSS_RETA_SIZE_256];
+};
+
+struct zxdh_rss_hf {
+	uint32_t rss_hf;
+};
+
 
 struct zxdh_msg_reply_head {
 	uint8_t flag;
@@ -307,6 +320,8 @@ struct zxdh_msg_reply_body {
 	union {
 		uint8_t reply_data[ZXDH_MSG_REPLY_BODY_MAX_LEN - sizeof(enum zxdh_reps_flag)];
 		struct zxdh_link_info_msg link_msg;
+		struct zxdh_rss_hf rss_hf;
+		struct zxdh_rss_reta rss_reta;
 	} __rte_packed;
 } __rte_packed;
 
@@ -362,6 +377,10 @@ struct zxdh_vlan_offload {
 	uint8_t type;
 } __rte_packed;
 
+struct zxdh_rss_enable {
+	uint8_t enable;
+};
+
 struct zxdh_msg_head {
 	enum zxdh_msg_type msg_type;
 	uint16_t  vport;
@@ -385,6 +404,9 @@ struct zxdh_msg_info {
 		struct zxdh_vlan_filter vlan_filter_msg;
 		struct zxdh_vlan_filter_set vlan_filter_set_msg;
 		struct zxdh_vlan_offload vlan_offload_msg;
+		struct zxdh_rss_reta rss_reta;
+		struct zxdh_rss_enable rss_enable;
+		struct zxdh_rss_hf rss_hf;
 	} __rte_packed data;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_tables.c +82 -0

91 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +7 -0
index 85e95a876f..649ede33e8 100644
@@ -10,6 +10,7 @@
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 #define ZXDH_DEVICE_NO                    0
+#define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
 struct zxdh_port_attr_table {
@@ -198,6 +199,10 @@ struct zxdh_vlan_filter_table {
 	uint32_t vlans[4];
 };
 
+struct zxdh_rss_to_vqid_table {
+	uint16_t vqm_qid[8];
+};
+
 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);
@@ -211,5 +216,7 @@ int zxdh_dev_unicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 int zxdh_dev_multicast_table_set(struct zxdh_hw *hw, uint16_t vport, bool enable);
 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);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#277 lore raw

PATCH 14/15 net/zxdh: basic stats ops implementations

In reply to Junlong Wang

basic stats ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |   2 +
 doc/guides/nics/zxdh.rst           |   1 +
 drivers/net/zxdh/zxdh_ethdev.c     |   2 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 353 +++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  27 +++
 drivers/net/zxdh/zxdh_msg.h        |  15 ++
 drivers/net/zxdh/zxdh_np.c         | 349 ++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_np.h         |  30 +++
 drivers/net/zxdh/zxdh_queue.h      |   2 +
 drivers/net/zxdh/zxdh_rxtx.c       |  82 ++++++-
 drivers/net/zxdh/zxdh_tables.h     |   5 +
 11 files changed, 866 insertions(+), 2 deletions(-)
doc/guides/nics/features/zxdh.ini +2 -0
index 5cae08f611..39c2473652 100644
@@ -21,3 +21,5 @@ VLAN offload         = Y
 RSS hash             = Y
 RSS reta update      = Y
 Inner RSS            = Y
+Basic stats          = Y
+Stats per queue      = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +1 -0
index 3cc6a1d348..c8a52b587c 100644
@@ -32,6 +32,7 @@ Features of the ZXDH PMD are:
 - VLAN stripping and inserting
 - QINQ stripping and inserting
 - Receive Side Scaling (RSS)
+- Port hardware statistics
 
 
 Driver compilation and testing
drivers/net/zxdh/zxdh_ethdev.c +2 -0
index 87502adf74..82f81d1ded 100644
@@ -1141,6 +1141,8 @@ static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.reta_query				 = zxdh_dev_rss_reta_query,
 	.rss_hash_update		 = zxdh_rss_hash_update,
 	.rss_hash_conf_get		 = zxdh_rss_hash_conf_get,
+	.stats_get				 = zxdh_dev_stats_get,
+	.stats_reset			 = zxdh_dev_stats_reset,
 };
 
 static int32_t
drivers/net/zxdh/zxdh_ethdev_ops.c +353 -0

368 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +27 -0
index ef89c0d325..dad84934fc 100644
@@ -5,8 +5,33 @@
 #ifndef ZXDH_ETHDEV_OPS_H
 #define ZXDH_ETHDEV_OPS_H
 
+#include <stdint.h>
+
 #include "zxdh_ethdev.h"
 
+struct zxdh_hw_vqm_stats {
+	uint64_t rx_total;
+	uint64_t tx_total;
+	uint64_t rx_bytes;
+	uint64_t tx_bytes;
+	uint64_t rx_error;
+	uint64_t tx_error;
+	uint64_t rx_drop;
+} __rte_packed;
+
+struct zxdh_hw_np_stats {
+	uint64_t np_rx_broadcast;
+	uint64_t np_tx_broadcast;
+	uint64_t np_rx_mtu_drop_pkts;
+	uint64_t np_tx_mtu_drop_pkts;
+	uint64_t np_rx_mtu_drop_bytes;
+	uint64_t np_tx_mtu_drop_bytes;
+	uint64_t np_rx_mtr_drop_pkts;
+	uint64_t np_tx_mtr_drop_pkts;
+	uint64_t np_rx_mtr_drop_bytes;
+	uint64_t np_tx_mtr_drop_bytes;
+};
+
 int zxdh_dev_set_link_up(struct rte_eth_dev *dev);
 int zxdh_dev_set_link_down(struct rte_eth_dev *dev);
 int32_t zxdh_dev_link_update(struct rte_eth_dev *dev, int32_t wait_to_complete __rte_unused);
@@ -28,5 +53,7 @@ int zxdh_dev_rss_reta_query(struct rte_eth_dev *dev,
 			uint16_t reta_size);
 int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
+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);
 
 #endif /* ZXDH_ETHDEV_OPS_H */
drivers/net/zxdh/zxdh_msg.h +15 -0
index 57092abe92..5530fc70a7 100644
@@ -9,8 +9,13 @@
 
 #include <ethdev_driver.h>
 
+#include "zxdh_ethdev_ops.h"
+
 #define ZXDH_BAR0_INDEX                 0
 #define ZXDH_CTRLCH_OFFSET              (0x2000)
+#define ZXDH_MAC_OFFSET                 (0x24000)
+#define ZXDH_MAC_STATS_OFFSET           (0x1408)
+#define ZXDH_MAC_BYTES_OFFSET           (0xb000)
 #define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
@@ -172,7 +177,13 @@ enum pciebar_layout_type {
 
 /* riscv msg opcodes */
 enum zxdh_agent_msg_type {
+	ZXDH_MAC_STATS_GET = 10,
+	ZXDH_MAC_STATS_RESET,
 	ZXDH_MAC_LINK_GET = 14,
+	ZXDH_VQM_DEV_STATS_GET = 21,
+	ZXDH_VQM_DEV_STATS_RESET,
+	ZXDH_VQM_QUEUE_STATS_GET = 24,
+	ZXDH_VQM_QUEUE_STATS_RESET,
 } __rte_packed;
 
 enum zxdh_msg_type {
@@ -194,6 +205,8 @@ enum zxdh_msg_type {
 	ZXDH_PORT_ATTRS_SET = 25,
 	ZXDH_PORT_PROMISC_SET = 26,
 
+	ZXDH_GET_NP_STATS = 31,
+
 	ZXDH_MSG_TYPE_END,
 } __rte_packed;
 
@@ -322,6 +335,8 @@ struct zxdh_msg_reply_body {
 		struct zxdh_link_info_msg link_msg;
 		struct zxdh_rss_hf rss_hf;
 		struct zxdh_rss_reta rss_reta;
+		struct zxdh_hw_vqm_stats vqm_stats;
+		struct zxdh_hw_np_stats np_stats;
 	} __rte_packed;
 } __rte_packed;
 
drivers/net/zxdh/zxdh_np.c +349 -0

364 lines not on this page · raw message

drivers/net/zxdh/zxdh_np.h +30 -0
index 7295b709ce..fd59a46491 100644
@@ -432,6 +432,18 @@ typedef enum zxdh_sdt_table_type_e {
 	ZXDH_SDT_TBLT_MAX     = 7,
 } ZXDH_SDT_TABLE_TYPE_E;
 
+typedef enum zxdh_dtb_dir_type_e {
+	ZXDH_DTB_DIR_DOWN_TYPE    = 0,
+	ZXDH_DTB_DIR_UP_TYPE    = 1,
+	ZXDH_DTB_DIR_TYPE_MAX,
+} ZXDH_DTB_DIR_TYPE_E;
+
+typedef enum zxdh_dtb_tab_up_user_addr_type_e {
+	ZXDH_DTB_TAB_UP_NOUSER_ADDR_TYPE     = 0,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE       = 1,
+	ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_MAX,
+} ZXDH_DTB_TAB_UP_USER_ADDR_TYPE_E;
+
 typedef struct zxdh_dtb_lpm_entry_t {
 	uint32_t dtb_len0;
 	uint8_t *p_data_buff0;
@@ -537,6 +549,19 @@ typedef struct zxdh_sdt_tbl_porttbl_t {
 	uint32_t porttbl_clutch_en;
 } ZXDH_SDTTBL_PORTTBL_T;
 
+typedef struct zxdh_ppu_stat_cfg_t {
+	uint32_t eram_baddr;
+	uint32_t eram_depth;
+	uint32_t ddr_base_addr;
+	uint32_t ppu_addr_offset;
+} ZXDH_PPU_STAT_CFG_T;
+
+typedef enum zxdh_stat_cnt_mode_e {
+	ZXDH_STAT_64_MODE  = 0,
+	ZXDH_STAT_128_MODE = 1,
+	ZXDH_STAT_MAX_MODE,
+} ZXDH_STAT_CNT_MODE_E;
+
 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,
@@ -545,5 +570,10 @@ 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);
 int zxdh_np_dtb_table_entry_get(uint32_t dev_id, uint32_t queue_id,
 			ZXDH_DTB_USER_ENTRY_T *get_entry, uint32_t srh_mode);
+int zxdh_np_dtb_stats_get(uint32_t dev_id,
+			uint32_t queue_id,
+			ZXDH_STAT_CNT_MODE_E rd_mode,
+			uint32_t index,
+			uint32_t *p_data);
 
 #endif /* ZXDH_NP_H */
drivers/net/zxdh/zxdh_queue.h +2 -0
index 1bd292e235..af616d115b 100644
@@ -53,6 +53,8 @@ enum { ZXDH_VTNET_RQ = 0, ZXDH_VTNET_TQ = 1 };
 #define ZXDH_PI_HDR_SIZE          sizeof(struct zxdh_pi_hdr)
 #define ZXDH_DL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_dl)
 #define ZXDH_UL_NET_HDR_SIZE      sizeof(struct zxdh_net_hdr_ul)
+#define ZXDH_PD_HDR_SIZE_MAX              256
+#define ZXDH_PD_HDR_SIZE_MIN              ZXDH_TYPE_HDR_SIZE
 
 /*
  * ring descriptors: 16 bytes.
drivers/net/zxdh/zxdh_rxtx.c +80 -2

165 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +5 -0
index 649ede33e8..675c7871ae 100644
@@ -13,6 +13,11 @@ extern struct zxdh_dtb_shared_data g_dtb_data;
 #define ZXDH_PORT_BASE_QID_FLAG           10
 #define ZXDH_PORT_ATTR_IS_UP_FLAG         35
 
+#define ZXDH_MTU_STATS_EGRESS_BASE        0x8481
+#define ZXDH_MTU_STATS_INGRESS_BASE       0x8981
+#define ZXDH_BROAD_STATS_EGRESS_BASE      0xC902
+#define ZXDH_BROAD_STATS_INGRESS_BASE     0xD102
+
 struct zxdh_port_attr_table {
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 	uint8_t byte4_rsv1: 1;
Signature · 1 line
2.27.0
#278 lore raw

PATCH 15/15 net/zxdh: mtu update ops implementations

In reply to Junlong Wang

mtu update ops implementations.

---
 doc/guides/nics/features/zxdh.ini  |  3 +-
 doc/guides/nics/zxdh.rst           |  2 +
 drivers/net/zxdh/zxdh_ethdev.c     |  1 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 79 ++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev_ops.h |  1 +
 drivers/net/zxdh/zxdh_tables.c     | 42 ++++++++++++++++
 drivers/net/zxdh/zxdh_tables.h     |  4 ++
 7 files changed, 131 insertions(+), 1 deletion(-)
doc/guides/nics/features/zxdh.ini +2 -1
index 39c2473652..b9bdb73ddf 100644
@@ -22,4 +22,5 @@ RSS hash             = Y
 RSS reta update      = Y
 Inner RSS            = Y
 Basic stats          = Y
-Stats per queue      = Y
\ No newline at end of file
+Stats per queue      = Y
+MTU update           = Y
\ No newline at end of file
doc/guides/nics/zxdh.rst +2 -0
index c8a52b587c..58e0c49a2e 100644
@@ -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
drivers/net/zxdh/zxdh_ethdev.c +1 -0
index 82f81d1ded..8f39f41c4e 100644
@@ -1143,6 +1143,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
drivers/net/zxdh/zxdh_ethdev_ops.c +79 -0

94 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev_ops.h +1 -0
index dad84934fc..3f37c35178 100644
@@ -55,5 +55,6 @@ int zxdh_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_c
 int zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);
 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 */
drivers/net/zxdh/zxdh_tables.c +42 -0

48 lines not on this page · raw message

drivers/net/zxdh/zxdh_tables.h +4 -0
index 675c7871ae..d176ec2ed3 100644
@@ -10,8 +10,10 @@
 extern struct zxdh_dtb_shared_data g_dtb_data;
 
 #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_att);
+int zxdh_set_panel_attr(struct rte_eth_dev *dev, struct zxdh_panel_table *panel_att);
 
 #endif /* ZXDH_TABLES_H */
Signature · 1 line
2.27.0
#279 lore raw

PATCH v10 2/10 net/zxdh: add logging implementation

In reply to Junlong Wang

Add zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 14 ++++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +12 -2
index 8689e56309..b64dddc91e 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
@@ -20,13 +21,18 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_DRV_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -95,3 +101,7 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +34 -0
new file mode 100644
index 0000000000..53838e313b
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_LOGS_H
+#define ZXDH_LOGS_H
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_rx;
+#define RTE_LOGTYPE_ZXDH_RX zxdh_logtype_rx
+#define PMD_RX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_RX, "zxdh rx %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_tx;
+#define RTE_LOGTYPE_ZXDH_TX zxdh_logtype_tx
+#define PMD_TX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_TX, "zxdh tx %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_msg;
+#define RTE_LOGTYPE_ZXDH_MSG zxdh_logtype_msg
+#define PMD_MSG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_MSG, "zxdh msg %s(): ", \
+		__func__, __VA_ARGS__)
+
+#endif /* ZXDH_LOGS_H */
Signature · 1 line
2.27.0
#280 lore raw

PATCH v10 3/10 net/zxdh: add zxdh device pci init implementation

In reply to Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  44 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  18 ++-
 drivers/net/zxdh/zxdh_pci.c    | 283 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 138 ++++++++++++++++
 5 files changed, 483 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
drivers/net/zxdh/meson.build +1 -0
index 932fb1c835..7db4e7bc71 100644
@@ -15,4 +15,5 @@ endif
 
 sources = files(
         'zxdh_ethdev.c',
+        'zxdh_pci.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +44 -0

56 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +17 -1
index a11e3624a9..a22ac15065 100644
@@ -5,6 +5,7 @@
 #ifndef ZXDH_ETHDEV_H
 #define ZXDH_ETHDEV_H
 
+#include <rte_ether.h>
 #include "ethdev_driver.h"
 
 #ifdef __cplusplus
@@ -24,15 +25,30 @@ extern "C" {
 #define ZXDH_MAX_MAC_ADDRS        (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
 #define ZXDH_NUM_BARS             2
+#define ZXDH_RX_QUEUES_MAX        128U
+#define ZXDH_TX_QUEUES_MAX        128U
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +283 -0

283 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +138 -0

138 lines not on this page · raw message

Signature · 1 line
2.27.0
#281 lore raw

PATCH v10 4/10 net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang

Add msg channel and hwlock init implementation

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  15 +++
 drivers/net/zxdh/zxdh_ethdev.h |   1 +
 drivers/net/zxdh/zxdh_msg.c    | 170 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  67 +++++++++++++
 5 files changed, 254 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
drivers/net/zxdh/meson.build +1 -0
index 7db4e7bc71..2e0c8fddae 100644
@@ -16,4 +16,5 @@ endif
 sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
+        'zxdh_msg.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index ae20e00317..bb7c1253c9 100644
@@ -9,6 +9,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
+#include "zxdh_msg.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -85,9 +86,23 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_msg_chan_init();
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Failed to init bar msg chan");
+		goto err_zxdh_init;
+	}
+	hw->msg_chan_init = 1;
+
+	ret = zxdh_msg_chan_hwlock_init(eth_dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +1 -0
index a22ac15065..20ead56e44 100644
@@ -51,6 +51,7 @@ struct zxdh_hw {
 
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t msg_chan_init;
 };
 
 #ifdef __cplusplus
drivers/net/zxdh/zxdh_msg.c new file +170 -0

170 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.27.0
#282 lore raw

PATCH v10 5/10 net/zxdh: add msg chan enable implementation

In reply to Junlong Wang

Add msg chan enable implementation to support
send msg to backend(device side) get infos.

---
 drivers/net/zxdh/zxdh_ethdev.c |   6 +
 drivers/net/zxdh/zxdh_ethdev.h |  12 +
 drivers/net/zxdh/zxdh_msg.c    | 657 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    | 128 +++++++
 4 files changed, 803 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +6 -0
index bb7c1253c9..105c18f9e0 100644
@@ -99,6 +99,12 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_msg_chan_enable(eth_dev);
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "zxdh_msg_bar_chan_enable failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +12 -0
index 20ead56e44..7434cc15d7 100644
@@ -28,10 +28,22 @@ extern "C" {
 #define ZXDH_RX_QUEUES_MAX        128U
 #define ZXDH_TX_QUEUES_MAX        128U
 
+union zxdh_virport_num {
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
drivers/net/zxdh/zxdh_msg.c +657 -0

690 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +128 -0

150 lines not on this page · raw message

Signature · 1 line
2.27.0
#283 lore raw

PATCH v10 6/10 net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 256 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_common.h |  30 ++++
 drivers/net/zxdh/zxdh_ethdev.c |  37 +++++
 drivers/net/zxdh/zxdh_ethdev.h |   5 +
 drivers/net/zxdh/zxdh_msg.h    |  21 +++
 6 files changed, 350 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
drivers/net/zxdh/meson.build +1 -0
index 2e0c8fddae..a16db47f89 100644
@@ -17,4 +17,5 @@ sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
         'zxdh_msg.c',
+        'zxdh_common.c',
 )
drivers/net/zxdh/zxdh_common.c new file +256 -0

256 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +30 -0
new file mode 100644
index 0000000000..ba29ca1dad
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_COMMON_H
+#define ZXDH_COMMON_H
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct zxdh_res_para {
+	uint64_t virt_addr;
+	uint16_t pcie_id;
+	uint16_t src_type; /* refer to BAR_DRIVER_TYPE */
+};
+
+int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
+int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZXDH_COMMON_H */
drivers/net/zxdh/zxdh_ethdev.c +37 -0
index 105c18f9e0..da5ac3ccd1 100644
@@ -10,9 +10,22 @@
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
+#include "zxdh_common.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
+uint16_t
+zxdh_vport_to_vfid(union zxdh_virport_num v)
+{
+	/* epid > 4 is local soft queue. return 1192 */
+	if (v.epid > 4)
+		return 1192;
+	if (v.vf_flag)
+		return v.epid * 256 + v.vfid;
+	else
+		return (v.epid * 8 + v.pfid) + 1152;
+}
+
 static int32_t
 zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
@@ -45,6 +58,26 @@ zxdh_init_device(struct rte_eth_dev *eth_dev)
 	return ret;
 }
 
+static int
+zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
+{
+	if (zxdh_phyport_get(eth_dev, &hw->phyport) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get phyport");
+		return -1;
+	}
+	PMD_DRV_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+
+	hw->vfid = zxdh_vport_to_vfid(hw->vport);
+
+	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to get panel_id");
+		return -1;
+	}
+	PMD_DRV_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+
+	return 0;
+}
+
 static int
 zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -105,6 +138,10 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_agent_comm(eth_dev, hw);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +5 -0
index 7434cc15d7..7b7bb16be8 100644
@@ -55,6 +55,7 @@ struct zxdh_hw {
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
+	uint16_t vfid;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -64,8 +65,12 @@ struct zxdh_hw {
 	uint8_t duplex;
 	uint8_t is_pf;
 	uint8_t msg_chan_init;
+	uint8_t phyport;
+	uint8_t panel_id;
 };
 
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_msg.h +21 -0
index 83e2fe6d5b..b2beedec64 100644
@@ -107,6 +107,27 @@ enum ZXDH_BAR_MODULE_ID {
 	ZXDH_BAR_MSG_MODULE_NUM = 100,
 };
 
+enum ZXDH_RES_TBL_FILED {
+	ZXDH_TBL_FIELD_PCIEID     = 0,
+	ZXDH_TBL_FIELD_BDF        = 1,
+	ZXDH_TBL_FIELD_MSGCH      = 2,
+	ZXDH_TBL_FIELD_DATACH     = 3,
+	ZXDH_TBL_FIELD_VPORT      = 4,
+	ZXDH_TBL_FIELD_PNLID      = 5,
+	ZXDH_TBL_FIELD_PHYPORT    = 6,
+	ZXDH_TBL_FIELD_SERDES_NUM = 7,
+	ZXDH_TBL_FIELD_NP_PORT    = 8,
+	ZXDH_TBL_FIELD_SPEED      = 9,
+	ZXDH_TBL_FIELD_HASHID     = 10,
+	ZXDH_TBL_FIELD_NON,
+};
+
+enum ZXDH_TBL_MSG_TYPE {
+	ZXDH_TBL_TYPE_READ,
+	ZXDH_TBL_TYPE_WRITE,
+	ZXDH_TBL_TYPE_NON,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
Signature · 1 line
2.27.0
#284 lore raw

PATCH v10 7/10 net/zxdh: add configure zxdh intr implementation

In reply to Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

---
 drivers/net/zxdh/zxdh_ethdev.c | 315 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |   6 +
 drivers/net/zxdh/zxdh_msg.c    | 210 ++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  16 +-
 drivers/net/zxdh/zxdh_pci.c    |  31 ++++
 drivers/net/zxdh/zxdh_pci.h    |  11 ++
 drivers/net/zxdh/zxdh_queue.h  | 110 ++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  55 ++++++
 8 files changed, 752 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/zxdh_ethdev.c +315 -0
index da5ac3ccd1..1a3658e74b 100644
@@ -11,6 +11,7 @@
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
 #include "zxdh_common.h"
+#include "zxdh_queue.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -26,6 +27,315 @@ zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static void
+zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2 + 1], ZXDH_MSI_NO_VECTOR);
+	}
+}
+
+
+static int32_t
+zxdh_intr_unmask(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (rte_intr_ack(dev->intr_handle) < 0)
+		return -1;
+
+	hw->use_msix = zxdh_pci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));
+
+	return 0;
+}
+
+static void
+zxdh_devconf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+
+	if (zxdh_intr_unmask(dev) < 0)
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+}
+
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void
+zxdh_fromriscv_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_CTRLCH_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_DRV_LOG(DEBUG, "zxdh_risc2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_DRV_LOG(DEBUG, "zxdh_riscvf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void
+zxdh_frompfvf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] +
+				ZXDH_MSG_CHAN_PFVFSHARE_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_DRV_LOG(DEBUG, "zxdh_vf2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_VF, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_DRV_LOG(DEBUG, "zxdh_pf2vf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_PF, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+static void
+zxdh_intr_cb_reg(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_register(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_register(tmp, zxdh_frompfvf_intr_handler, dev);
+
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_register(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static void
+zxdh_intr_cb_unreg(struct rte_eth_dev *dev)
+{
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_unregister(tmp, zxdh_frompfvf_intr_handler, dev);
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_unregister(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static int32_t
+zxdh_intr_disable(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled)
+		return 0;
+
+	zxdh_intr_cb_unreg(dev);
+	if (rte_intr_disable(dev->intr_handle) < 0)
+		return -1;
+
+	hw->intr_enabled = 0;
+	return 0;
+}
+
+static int32_t
+zxdh_intr_enable(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled) {
+		zxdh_intr_cb_reg(dev);
+		ret = rte_intr_enable(dev->intr_handle);
+		if (unlikely(ret))
+			PMD_DRV_LOG(ERR, "Failed to enable %s intr", dev->data->name);
+
+		hw->intr_enabled = 1;
+	}
+	return ret;
+}
+
+static int32_t
+zxdh_intr_release(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		ZXDH_VTPCI_OPS(hw)->set_config_irq(hw, ZXDH_MSI_NO_VECTOR);
+
+	zxdh_queues_unbind_intr(dev);
+	zxdh_intr_disable(dev);
+
+	rte_intr_efd_disable(dev->intr_handle);
+	rte_intr_vec_list_free(dev->intr_handle);
+	rte_free(hw->risc_intr);
+	hw->risc_intr = NULL;
+	rte_free(hw->dtb_intr);
+	hw->dtb_intr = NULL;
+	return 0;
+}
+
+static int32_t
+zxdh_setup_risc_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint8_t i;
+
+	if (!hw->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) {
+			PMD_DRV_LOG(ERR, "Failed to allocate risc_intr");
+			return -ENOMEM;
+		}
+	}
+
+	for (i = 0; i < ZXDH_MSIX_INTR_MSG_VEC_NUM; i++) {
+		if (dev->intr_handle->efds[i] < 0) {
+			PMD_DRV_LOG(ERR, "[%u]risc interrupt fd is invalid", i);
+			rte_free(hw->risc_intr);
+			hw->risc_intr = NULL;
+			return -1;
+		}
+
+		struct rte_intr_handle *intr_handle = hw->risc_intr + i;
+
+		intr_handle->fd = dev->intr_handle->efds[i];
+		intr_handle->type = dev->intr_handle->type;
+	}
+
+	return 0;
+}
+
+static int32_t
+zxdh_setup_dtb_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->dtb_intr) {
+		hw->dtb_intr = rte_zmalloc("dtb_intr", sizeof(struct rte_intr_handle), 0);
+		if (hw->dtb_intr == NULL) {
+			PMD_DRV_LOG(ERR, "Failed to allocate dtb_intr");
+			return -ENOMEM;
+		}
+	}
+
+	if (dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1] < 0) {
+		PMD_DRV_LOG(ERR, "[%d]dtb interrupt fd is invalid", ZXDH_MSIX_INTR_DTB_VEC - 1);
+		rte_free(hw->dtb_intr);
+		hw->dtb_intr = NULL;
+		return -1;
+	}
+	hw->dtb_intr->fd = dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1];
+	hw->dtb_intr->type = dev->intr_handle->type;
+	return 0;
+}
+
+static int32_t
+zxdh_queues_bind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+	uint16_t vec;
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+			PMD_DRV_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+					i * 2, ZXDH_MSI_NO_VECTOR, vec);
+		}
+	} else {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], i + ZXDH_QUEUE_INTR_VEC_BASE);
+			PMD_DRV_LOG(DEBUG, "vq%d irq set %d, get %d",
+					i * 2, i + ZXDH_QUEUE_INTR_VEC_BASE, vec);
+		}
+	}
+	/* mask all txq intr */
+	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
+		vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+				hw->vqs[(i * 2) + 1], ZXDH_MSI_NO_VECTOR);
+		PMD_DRV_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+				(i * 2) + 1, ZXDH_MSI_NO_VECTOR, vec);
+	}
+	return 0;
+}
+
+static int32_t
+zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t ret = 0;
+
+	if (!rte_intr_cap_multiple(dev->intr_handle)) {
+		PMD_DRV_LOG(ERR, "Multiple intr vector not supported");
+		return -ENOTSUP;
+	}
+	zxdh_intr_release(dev);
+	uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+	if (dev->data->dev_conf.intr_conf.rxq)
+		nb_efd += dev->data->nb_rx_queues;
+
+	if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+		PMD_DRV_LOG(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+		PMD_DRV_LOG(ERR, "Failed to allocate %u rxq vectors",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+		return -ENOMEM;
+	}
+	PMD_DRV_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle->vec_list_size);
+	if (zxdh_setup_risc_interrupts(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Error setting up rsic_v interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	if (zxdh_setup_dtb_interrupts(dev) != 0) {
+		PMD_DRV_LOG(ERR, "Error setting up dtb interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_queues_bind_intr(dev) < 0) {
+		PMD_DRV_LOG(ERR, "Failed to bind queue/interrupt");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_intr_enable(dev) < 0) {
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	return 0;
+
+free_intr_vec:
+	zxdh_intr_release(dev);
+	return ret;
+}
+
 static int32_t
 zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
@@ -142,9 +452,14 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_configure_intr(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_intr_release(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_ethdev.h +6 -0
index 7b7bb16be8..65726f3a20 100644
@@ -7,6 +7,8 @@
 
 #include <rte_ether.h>
 #include "ethdev_driver.h"
+#include <rte_interrupts.h>
+#include <eal_interrupts.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -43,6 +45,9 @@ struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	struct rte_intr_handle *risc_intr;
+	struct rte_intr_handle *dtb_intr;
+	struct zxdh_virtqueue **vqs;
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -59,6 +64,7 @@ struct zxdh_hw {
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
+	uint8_t intr_enabled;
 	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 
drivers/net/zxdh/zxdh_msg.c +210 -0

225 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +14 -2
index b2beedec64..5742000a3b 100644
@@ -13,10 +13,17 @@
 extern "C" {
 #endif
 
-#define ZXDH_BAR0_INDEX     0
-#define ZXDH_CTRLCH_OFFSET            (0x2000)
+#define ZXDH_BAR0_INDEX                 0
+#define ZXDH_CTRLCH_OFFSET              (0x2000)
+#define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
+#define ZXDH_MSIX_INTR_MSG_VEC_NUM    3
+#define ZXDH_MSIX_INTR_DTB_VEC        (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
+#define ZXDH_MSIX_INTR_DTB_VEC_NUM    1
+#define ZXDH_INTR_NONQUE_NUM          (ZXDH_MSIX_INTR_MSG_VEC_NUM + ZXDH_MSIX_INTR_DTB_VEC_NUM + 1)
+#define ZXDH_QUEUE_INTR_VEC_BASE      (ZXDH_MSIX_INTR_DTB_VEC + ZXDH_MSIX_INTR_DTB_VEC_NUM)
+#define ZXDH_QUEUE_INTR_VEC_NUM       256
 
 #define ZXDH_BAR_MSG_POLLING_SPAN     100
 #define ZXDH_BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / ZXDH_BAR_MSG_POLLING_SPAN)
@@ -201,6 +208,9 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
+		void *reps_buffer, uint16_t *reps_len, void *dev);
+
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
@@ -209,6 +219,8 @@ int zxdh_msg_chan_enable(struct rte_eth_dev *dev);
 int zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in,
 		struct zxdh_msg_recviver_mem *result);
 
+int zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_pci.c +31 -0
index 68785aa03e..8e7a9c1213 100644
@@ -14,6 +14,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_pci.h"
 #include "zxdh_logs.h"
+#include "zxdh_queue.h"
 
 #define ZXDH_PMD_DEFAULT_GUEST_FEATURES   \
 		(1ULL << ZXDH_NET_F_MRG_RXBUF | \
@@ -93,6 +94,27 @@ zxdh_set_features(struct zxdh_hw *hw, uint64_t features)
 	rte_write32(features >> 32, &hw->common_cfg->guest_feature);
 }
 
+static uint16_t
+zxdh_set_config_irq(struct zxdh_hw *hw, uint16_t vec)
+{
+	rte_write16(vec, &hw->common_cfg->msix_config);
+	return rte_read16(&hw->common_cfg->msix_config);
+}
+
+static uint16_t
+zxdh_set_queue_irq(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec)
+{
+	rte_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
+	rte_write16(vec, &hw->common_cfg->queue_msix_vector);
+	return rte_read16(&hw->common_cfg->queue_msix_vector);
+}
+
+static uint8_t
+zxdh_get_isr(struct zxdh_hw *hw)
+{
+	return rte_read8(hw->isr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -100,8 +122,17 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_status     = zxdh_set_status,
 	.get_features   = zxdh_get_features,
 	.set_features   = zxdh_set_features,
+	.set_queue_irq  = zxdh_set_queue_irq,
+	.set_config_irq = zxdh_set_config_irq,
+	.get_isr        = zxdh_get_isr,
 };
 
+uint8_t
+zxdh_pci_isr(struct zxdh_hw *hw)
+{
+	return ZXDH_VTPCI_OPS(hw)->get_isr(hw);
+}
+
 uint16_t
 zxdh_pci_get_features(struct zxdh_hw *hw)
 {
drivers/net/zxdh/zxdh_pci.h +11 -0
index 7905911a34..41e47d5d3b 100644
@@ -22,6 +22,13 @@ enum zxdh_msix_status {
 	ZXDH_MSIX_ENABLED  = 2
 };
 
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define ZXDH_PCI_ISR_INTR    0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define ZXDH_PCI_ISR_CONFIG  0x2
+/* Vector value used to disable MSI for queue. */
+#define ZXDH_MSI_NO_VECTOR   0x7F
+
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
@@ -110,6 +117,9 @@ struct zxdh_pci_ops {
 
 	uint64_t (*get_features)(struct zxdh_hw *hw);
 	void     (*set_features)(struct zxdh_hw *hw, uint64_t features);
+	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
+	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
+	uint8_t  (*get_isr)(struct zxdh_hw *hw);
 };
 
 struct zxdh_hw_internal {
@@ -130,6 +140,7 @@ void zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 
 uint16_t zxdh_pci_get_features(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_pci_msix_detect(struct rte_pci_device *dev);
+uint8_t zxdh_pci_isr(struct zxdh_hw *hw);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_queue.h new file +110 -0

110 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.27.0
#285 lore raw

PATCH v10 8/10 net/zxdh: add zxdh dev infos get ops

In reply to Junlong Wang

Add support for zxdh infos get.

---
 drivers/net/zxdh/zxdh_ethdev.c | 45 +++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_ethdev.h |  2 ++
 2 files changed, 46 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +44 -1
index 1a3658e74b..11ec5dc34f 100644
@@ -27,6 +27,44 @@ zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static int32_t
+zxdh_dev_infos_get(struct rte_eth_dev *dev,
+		struct rte_eth_dev_info *dev_info)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	dev_info->speed_capa       = rte_eth_speed_bitflag(hw->speed, RTE_ETH_LINK_FULL_DUPLEX);
+	dev_info->max_rx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_RX_QUEUES_MAX);
+	dev_info->max_tx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_TX_QUEUES_MAX);
+	dev_info->min_rx_bufsize   = ZXDH_MIN_RX_BUFSIZE;
+	dev_info->max_rx_pktlen    = ZXDH_MAX_RX_PKTLEN;
+	dev_info->max_mac_addrs    = ZXDH_MAX_MAC_ADDRS;
+	dev_info->rx_offload_capa  = (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+					RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
+					RTE_ETH_RX_OFFLOAD_QINQ_STRIP);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_SCATTER);
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_TCP_LRO;
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	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);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
+					RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+					RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM);
+
+	return 0;
+}
+
 static void
 zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
 {
@@ -336,6 +374,11 @@ zxdh_configure_intr(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+	.dev_infos_get			 = zxdh_dev_infos_get,
+};
+
 static int32_t
 zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
@@ -395,7 +438,7 @@ zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
 	int ret = 0;
 
-	eth_dev->dev_ops = NULL;
+	eth_dev->dev_ops = &zxdh_eth_dev_ops;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 65726f3a20..89c5a9bb5f 100644
@@ -29,6 +29,8 @@ extern "C" {
 #define ZXDH_NUM_BARS             2
 #define ZXDH_RX_QUEUES_MAX        128U
 #define ZXDH_TX_QUEUES_MAX        128U
+#define ZXDH_MIN_RX_BUFSIZE       64
+#define ZXDH_MAX_RX_PKTLEN        14000U
 
 union zxdh_virport_num {
 	uint16_t vport;
Signature · 1 line
2.27.0
#286 lore raw

PATCH v10 9/10 net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 144 +++++++++++
 drivers/net/zxdh/zxdh_common.h |  11 +
 drivers/net/zxdh/zxdh_ethdev.c | 459 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |  16 ++
 drivers/net/zxdh/zxdh_pci.c    | 106 ++++++++
 drivers/net/zxdh/zxdh_pci.h    |  30 ++-
 drivers/net/zxdh/zxdh_queue.c  | 127 +++++++++
 drivers/net/zxdh/zxdh_queue.h  | 175 +++++++++++++
 9 files changed, 1068 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
drivers/net/zxdh/meson.build +1 -0
index a16db47f89..b96aa5a27e 100644
@@ -18,4 +18,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_msg.c',
         'zxdh_common.c',
+        'zxdh_queue.c',
 )
drivers/net/zxdh/zxdh_common.c +144 -0

153 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h +11 -0
index ba29ca1dad..4a06da9495 100644
@@ -14,6 +14,10 @@
 extern "C" {
 #endif
 
+#define ZXDH_VF_LOCK_REG               0x90
+#define ZXDH_VF_LOCK_ENABLE_MASK       0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX   10
+
 struct zxdh_res_para {
 	uint64_t virt_addr;
 	uint16_t pcie_id;
@@ -22,6 +26,13 @@ struct zxdh_res_para {
 
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+void zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_timedlock(struct zxdh_hw *hw, uint32_t us);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+int32_t zxdh_datach_set(struct rte_eth_dev *dev);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_ethdev.c +459 -0

467 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +16 -0
index 89c5a9bb5f..28e78b0086 100644
@@ -31,6 +31,13 @@ extern "C" {
 #define ZXDH_TX_QUEUES_MAX        128U
 #define ZXDH_MIN_RX_BUFSIZE       64
 #define ZXDH_MAX_RX_PKTLEN        14000U
+#define ZXDH_QUEUE_DEPTH          1024
+#define ZXDH_QUEUES_BASE          0
+#define ZXDH_TOTAL_QUEUES_NUM     4096
+#define ZXDH_QUEUES_NUM_MAX       256
+#define ZXDH_QUERES_SHARE_BASE    (0x5000)
+
+#define ZXDH_MBUF_BURST_SZ        64
 
 union zxdh_virport_num {
 	uint16_t vport;
@@ -43,6 +50,11 @@ union zxdh_virport_num {
 	};
 };
 
+struct zxdh_chnl_context {
+	uint16_t valid;
+	uint16_t ph_chno;
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
@@ -50,6 +62,7 @@ struct zxdh_hw {
 	struct rte_intr_handle *risc_intr;
 	struct rte_intr_handle *dtb_intr;
 	struct zxdh_virtqueue **vqs;
+	struct zxdh_chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -63,6 +76,7 @@ struct zxdh_hw {
 	uint16_t device_id;
 	uint16_t port_id;
 	uint16_t vfid;
+	uint16_t queue_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -75,6 +89,8 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t has_tx_offload;
+	uint8_t has_rx_offload;
 };
 
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
drivers/net/zxdh/zxdh_pci.c +106 -0

124 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +29 -1
index 41e47d5d3b..2e7aa9c410 100644
@@ -29,7 +29,20 @@ enum zxdh_msix_status {
 /* Vector value used to disable MSI for queue. */
 #define ZXDH_MSI_NO_VECTOR   0x7F
 
+#define ZXDH_PCI_VRING_ALIGN         4096
+
+#define ZXDH_NET_F_CSUM              0   /* Host handles pkts w/ partial csum */
+#define ZXDH_NET_F_GUEST_CSUM        1   /* Guest handles pkts w/ partial csum */
+#define ZXDH_NET_F_MTU               3   /* Initial MTU advice. */
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
+#define ZXDH_NET_F_GUEST_TSO4        7   /* Guest can handle TSOv4 in. */
+#define ZXDH_NET_F_GUEST_TSO6        8   /* Guest can handle TSOv6 in. */
+#define ZXDH_NET_F_GUEST_ECN         9   /* Guest can handle TSO[6] w/ ECN in. */
+#define ZXDH_NET_F_GUEST_UFO         10  /* Guest can handle UFO in. */
+
+#define ZXDH_NET_F_HOST_UFO          14  /* Host can handle UFO in. */
+#define ZXDH_NET_F_HOST_TSO4         11  /* Host can handle TSOv4 in. */
+#define ZXDH_NET_F_HOST_TSO6         12  /* Host can handle TSOv6 in. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
 #define ZXDH_NET_F_MQ                22  /* Device supports Receive Flow Steering */
@@ -53,6 +66,7 @@ enum zxdh_msix_status {
 #define ZXDH_CONFIG_STATUS_FEATURES_OK     0x08
 #define ZXDH_CONFIG_STATUS_DEV_NEED_RESET  0x40
 #define ZXDH_CONFIG_STATUS_FAILED          0x80
+#define ZXDH_PCI_QUEUE_ADDR_SHIFT          12
 
 struct zxdh_net_config {
 	/* The config defining mac address (if ZXDH_NET_F_MAC) */
@@ -103,11 +117,18 @@ struct zxdh_pci_common_cfg {
 	uint32_t queue_used_hi;     /* read-write */
 };
 
-static inline int32_t vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
+static inline int32_t
+vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int32_t
+vtpci_packed_queue(struct zxdh_hw *hw)
+{
+	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+}
+
 struct zxdh_pci_ops {
 	void     (*read_dev_cfg)(struct zxdh_hw *hw, size_t offset, void *dst, int32_t len);
 	void     (*write_dev_cfg)(struct zxdh_hw *hw, size_t offset, const void *src, int32_t len);
@@ -120,6 +141,11 @@ struct zxdh_pci_ops {
 	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
 	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
 	uint8_t  (*get_isr)(struct zxdh_hw *hw);
+	uint16_t (*get_queue_num)(struct zxdh_hw *hw, uint16_t queue_id);
+	void     (*set_queue_num)(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size);
+
+	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
@@ -141,6 +167,8 @@ void zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 uint16_t zxdh_pci_get_features(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_pci_msix_detect(struct rte_pci_device *dev);
 uint8_t zxdh_pci_isr(struct zxdh_hw *hw);
+void zxdh_pci_reinit_complete(struct zxdh_hw *hw);
+void zxdh_pci_set_status(struct zxdh_hw *hw, uint8_t status);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_queue.c new file +127 -0

127 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +175 -0

198 lines not on this page · raw message

Signature · 1 line
2.27.0
#287 lore raw

PATCH v10 10/10 net/zxdh: add zxdh dev close ops

In reply to Junlong Wang

provided zxdh dev close ops for resource released.

---
 drivers/net/zxdh/zxdh_ethdev.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +23 -8
index 54e51a31fa..c786198535 100644
@@ -832,9 +832,32 @@ zxdh_dev_configure(struct rte_eth_dev *dev)
 	return ret;
 }
 
+static int
+zxdh_dev_close(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int ret = 0;
+
+	zxdh_intr_release(dev);
+	zxdh_pci_reset(hw);
+
+	zxdh_dev_free_mbufs(dev);
+	zxdh_free_queues(dev);
+
+	zxdh_bar_msg_chan_exit();
+
+	if (dev->data->mac_addrs != NULL) {
+		rte_free(dev->data->mac_addrs);
+		dev->data->mac_addrs = NULL;
+	}
+
+	return ret;
+}
+
 /* dev_ops for zxdh, bare necessities for basic operation */
 static const struct eth_dev_ops zxdh_eth_dev_ops = {
 	.dev_configure			 = zxdh_dev_configure,
+	.dev_close				 = zxdh_dev_close,
 	.dev_infos_get			 = zxdh_dev_infos_get,
 };
 
@@ -977,14 +1000,6 @@ zxdh_eth_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 						zxdh_eth_dev_init);
 }
 
-static int
-zxdh_dev_close(struct rte_eth_dev *dev __rte_unused)
-{
-	int ret = 0;
-
-	return ret;
-}
-
 static int
 zxdh_eth_dev_uninit(struct rte_eth_dev *eth_dev)
 {
Signature · 1 line
2.27.0
Acked-by on the v10 series
#288 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 37 lines · Junlong Wang

v10:
  -
 move zxdh under Wind River in MAINTAINERS and add myself as the maintainer and add experimental into MAINTAINERS/driver file,elease notes. - changed DPDK syntax is to have return value in a separate line. - Add a keyword in log types for distinguished.
  - using regular comments (non doxygen syntax).
  - fix other issues.

v9:
  - fix 'v8 3/9' patch use PCI bus API,
    and common PCI constants according to David Marchand's comments.

v8:
  - fix flexible arrays、Waddress-of-packed-member error. - all structs、enum、define ,etc use zxdh/ZXDH_ prefixed. - use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
  - add release notes and modify zxdh.rst issues. - avoid use pthread and use rte_spinlock_lock. - using the prefix ZXDH_ before some definitions. - resole issues according to thomas's comments.

v6:
  - Resolve ci/intel compilation issues.
  - fix meson.build indentation in earlier patch.

V5:
  - split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc. - fix errors reported by scripts.
  - move the product link in zxdh.rst.
  - fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
  - modify other comments according to Ferruh's comments.

Quoted 12 lines

Junlong Wang (10):
  net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops net/zxdh: add zxdh dev close ops

For series,

Series applied to dpdk-next-net/main, thanks.

#289 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

Quoted 51 lines · Ferruh Yigit
Quoted 37 lines · Junlong Wang

v10:
  -
 move zxdh under Wind River in MAINTAINERS and add myself as the maintainer and add experimental into MAINTAINERS/driver file,elease notes. - changed DPDK syntax is to have return value in a separate line. - Add a keyword in log types for distinguished.
  - using regular comments (non doxygen syntax).
  - fix other issues.

v9:
  - fix 'v8 3/9' patch use PCI bus API,
    and common PCI constants according to David Marchand's comments.

v8:
  - fix flexible arrays、Waddress-of-packed-member error. - all structs、enum、define ,etc use zxdh/ZXDH_ prefixed. - use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
  - add release notes and modify zxdh.rst issues. - avoid use pthread and use rte_spinlock_lock. - using the prefix ZXDH_ before some definitions. - resole issues according to thomas's comments.

v6:
  - Resolve ci/intel compilation issues.
  - fix meson.build indentation in earlier patch.

V5:
  - split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc. - fix errors reported by scripts.
  - move the product link in zxdh.rst.
  - fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
  - modify other comments according to Ferruh's comments.

Quoted 12 lines

Junlong Wang (10):
  net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops net/zxdh: add zxdh dev close ops

Quoted 5 lines

For series,

Series applied to dpdk-next-net/main, thanks.

Hi Junlong,

It seems we missed to mark driver as experimental, I will update it in next-net.

#290 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

Quoted 55 lines · Ferruh Yigit
Quoted 54 lines · Ferruh Yigit
Quoted 37 lines · Junlong Wang

v10:
  -
 move zxdh under Wind River in MAINTAINERS and add myself as the maintainer and add experimental into MAINTAINERS/driver file,elease notes. - changed DPDK syntax is to have return value in a separate line. - Add a keyword in log types for distinguished.
  - using regular comments (non doxygen syntax).
  - fix other issues.

v9:
  - fix 'v8 3/9' patch use PCI bus API,
    and common PCI constants according to David Marchand's comments.

v8:
  - fix flexible arrays、Waddress-of-packed-member error. - all structs、enum、define ,etc use zxdh/ZXDH_ prefixed. - use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
  - add release notes and modify zxdh.rst issues. - avoid use pthread and use rte_spinlock_lock. - using the prefix ZXDH_ before some definitions. - resole issues according to thomas's comments.

v6:
  - Resolve ci/intel compilation issues.
  - fix meson.build indentation in earlier patch.

V5:
  - split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc. - fix errors reported by scripts.
  - move the product link in zxdh.rst.
  - fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
  - modify other comments according to Ferruh's comments.

Quoted 12 lines

Junlong Wang (10):
  net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops net/zxdh: add zxdh dev close ops

For series,

Quoted 8 lines
Quoted 2 lines

Series applied to dpdk-next-net/main, thanks.

Hi Junlong,

It seems we missed to mark driver as experimental, I will update it in next-net.

Following applied:

diff --git a/MAINTAINERS b/MAINTAINERS
index 9a812b3632b7..e6e53e39683a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1058,7 +1058,7 @@ F: drivers/net/avp/
F: doc/guides/nics/avp.rst
F: doc/guides/nics/features/avp.ini

-ZTE zxdh
+ZTE zxdh - EXPERIMENTAL
M: Junlong Wang <[email protected]>
M: Lijie Shan <[email protected]>
F: drivers/net/zxdh/

#291 lore raw

Re: [PATCH v10 00/10] net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 9 lines
Quoted 8 lines · Ferruh Yigit
Quoted 5 lines

For series,

Series applied to dpdk-next-net/main, thanks.

Hi Junlong,

Quoted 8 lines
Quoted 2 lines

It seems we missed to mark driver as experimental, I will update it in next-net.

Sorry, I'm too careless, I will pay more attention next time. Thank you very much.

I'm removing the useless #ifdef __cplusplus while pulling in main, as we are trying to clean them in the repo.

OK, Thank you for helping with the modifications. I will pay attention in next submission.

#292 lore raw

PATCH v9 2/9 net/zxdh: add logging implementation

In reply to Junlong Wang

Add zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 15 +++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 40 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +13 -2
index 5b6c9ec1bf..c911284423 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -19,13 +20,18 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_INIT_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -90,3 +96,8 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +40 -0
new file mode 100644
index 0000000000..a8a6a3135b
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_LOGS_H
+#define ZXDH_LOGS_H
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_init;
+#define RTE_LOGTYPE_ZXDH_INIT zxdh_logtype_init
+#define PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_INIT, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_rx;
+#define RTE_LOGTYPE_ZXDH_RX zxdh_logtype_rx
+#define PMD_RX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_RX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_tx;
+#define RTE_LOGTYPE_ZXDH_TX zxdh_logtype_tx
+#define PMD_TX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_TX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_msg;
+#define RTE_LOGTYPE_ZXDH_MSG zxdh_logtype_msg
+#define PMD_MSG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_MSG, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+#endif /* ZXDH_LOGS_H */
Signature · 1 line
2.27.0
#293 lore raw

Re: [PATCH v9 2/9] net/zxdh: add logging implementation

Quoted 4 lines · Junlong Wang

Add zxdh logging implementation.

<...>

drivers/net/zxdh/zxdh_logs.h line 13

Quoted 5 lines
drivers/net/zxdh/zxdh_logs.h new file +4 -0
+extern int zxdh_logtype_init;
+#define RTE_LOGTYPE_ZXDH_INIT zxdh_logtype_init
+#define PMD_INIT_LOG(level, ...) \
+    RTE_LOG_LINE_PREFIX(level, ZXDH_INIT, "offload_zxdh %s(): ", \

Are you sure you want "offload_zxdh" prefix for each log, instead of shorter 'zxdh' one?

drivers/net/zxdh/zxdh_logs.h line 19

Quoted 7 lines

+        __func__, __VA_ARGS__)

drivers/net/zxdh/zxdh_logs.h new file +5 -0
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+    RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \

All log types seems same prefix, which is OK, but just a reminder if you want to distinguish them?

#294 lore raw

PATCH v9 2/9 net/zxdh: add logging implementation

In reply to Junlong Wang
Quoted 13 lines

Are you sure you want "offload_zxdh" prefix for each log, instead of shorter 'zxdh' one?

drivers/net/zxdh/zxdh_logs.h line 19

Quoted 7 lines
drivers/net/zxdh/zxdh_logs.h new file +6 -0
+        __func__, __VA_ARGS__)
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+    RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \

All log types seems same prefix, which is OK, but just a reminder if you want to distinguish them?

Thank you for your comments.

We will change it to 'zxdh' prefix..
Add a keyword, for example, "zxdh msg %s (): ""zxdh rx %s ():" "zxdh tx %s (): " to distinguish.

#295 lore raw

PATCH v9 3/9 net/zxdh: add zxdh device pci init implementation

In reply to Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  43 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  18 ++-
 drivers/net/zxdh/zxdh_pci.c    | 278 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 138 ++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 109 +++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  55 +++++++
 7 files changed, 641 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/meson.build +1 -0
index 932fb1c835..7db4e7bc71 100644
@@ -15,4 +15,5 @@ endif
 
 sources = files(
         'zxdh_ethdev.c',
+        'zxdh_pci.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +43 -0

55 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +17 -1
index a11e3624a9..a22ac15065 100644
@@ -5,6 +5,7 @@
 #ifndef ZXDH_ETHDEV_H
 #define ZXDH_ETHDEV_H
 
+#include <rte_ether.h>
 #include "ethdev_driver.h"
 
 #ifdef __cplusplus
@@ -24,15 +25,30 @@ extern "C" {
 #define ZXDH_MAX_MAC_ADDRS        (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
 #define ZXDH_NUM_BARS             2
+#define ZXDH_RX_QUEUES_MAX        128U
+#define ZXDH_TX_QUEUES_MAX        128U
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
 	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +278 -0

278 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +138 -0

138 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +109 -0

109 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.27.0
#296 lore raw

Re: [PATCH v9 3/9] net/zxdh: add zxdh device pci init implementation

Quoted 4 lines · Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

Quoted 9 lines

---
 drivers/net/zxdh/meson.build   |   1 + drivers/net/zxdh/zxdh_ethdev.c |  43 +++++ drivers/net/zxdh/zxdh_ethdev.h |  18 ++- drivers/net/zxdh/zxdh_pci.c    | 278 +++++++++++++++++++++++++++++++++ drivers/net/zxdh/zxdh_pci.h    | 138 ++++++++++++++++ drivers/net/zxdh/zxdh_queue.h  | 109 +++++++++++++ drivers/net/zxdh/zxdh_rxtx.h   |  55 +++++++

zxdh_queue.h & zxdh_rxtx.h seems not used in this patch, and they are not indeed related to the PCI init, or PCI at all.
Can you add them in the patch that they are used?

<...>

Quoted 6 lines
drivers/net/zxdh/zxdh_pci.c new file +5 -0
+#define ZXDH_PMD_DEFAULT_GUEST_FEATURES   \
+    (1ULL << ZXDH_NET_F_MRG_RXBUF | \
+     1ULL << ZXDH_NET_F_STATUS    | \
+     1ULL << ZXDH_NET_F_MQ        | \
+     1ULL << ZXDH_F_ANY_LAYOUT    | \

drivers/net/zxdh/zxdh_pci.c line 33

Quoted 10 lines
drivers/net/zxdh/zxdh_pci.c new file +10 -0
+     1ULL << ZXDH_F_VERSION_1     | \
+     1ULL << ZXDH_F_RING_PACKED   | \
+     1ULL << ZXDH_F_IN_ORDER      | \
+     1ULL << ZXDH_F_NOTIFICATION_DATA | \
+     1ULL << ZXDH_NET_F_MAC)
+
+static void zxdh_read_dev_config(struct zxdh_hw *hw,
+                                   size_t offset,
+                                   void *dst,
+                                   int32_t length)

Syntax issue, with tab stop = 8, above lines looks wrong can you please check?

<...>

Quoted 20 lines
drivers/net/zxdh/zxdh_queue.h new file +19 -0
+struct zxdh_virtqueue {
+    struct zxdh_hw  *hw; /**< zxdh_hw structure pointer. */
+    struct {
+        /**< vring keeping descs and events */
+        struct zxdh_vring_packed ring;
+        uint8_t used_wrap_counter;
+        uint8_t rsv;
+        uint16_t cached_flags; /**< cached flags for descs */
+        uint16_t event_flags_shadow;
+        uint16_t rsv1;
+    } __rte_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 */
+    uint16_t vq_avail_idx; /**< sync until needed */
+    uint16_t vq_free_thresh; /**< free threshold */
+    uint16_t rsv2;
+
+    void *vq_ring_virt_mem;  /**< linear address of vring*/

drivers/net/zxdh/zxdh_queue.h line 88

Quoted 10 lines
drivers/net/zxdh/zxdh_queue.h new file +10 -0
+    uint32_t vq_ring_size;
+
+    union {
+        struct zxdh_virtnet_rx rxq;
+        struct zxdh_virtnet_tx txq;
+    };
+
+    /** < physical address of vring,
+     * or virtual address
+     **/

'/**' is doxygen syntax, I don't know if you are using doxgen. But '/**<' is doxygen sytax to say comment is for the code before it, not after. So it is used wrong above.
If you don't have any specific reason, why not using regular comments (non doxygen syntax), and leave first line empty, and terminate with '*/', so above becomes:
/*
* physical address of vring, or virtual address
*/

This comment is for all comment code in all the series. It looks like there is a mixture of the usage.

#297 lore raw

PATCH v9 4/9 net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang

Add msg channel and hwlock init implementation.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  15 +++
 drivers/net/zxdh/zxdh_ethdev.h |   1 +
 drivers/net/zxdh/zxdh_msg.c    | 161 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  67 ++++++++++++++
 5 files changed, 245 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
drivers/net/zxdh/meson.build +1 -0
index 7db4e7bc71..2e0c8fddae 100644
@@ -16,4 +16,5 @@ endif
 sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
+        'zxdh_msg.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index 5c747882a7..da454cdff3 100644
@@ -9,6 +9,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
+#include "zxdh_msg.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_msg_chan_init();
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init bar msg chan");
+		goto err_zxdh_init;
+	}
+	hw->msg_chan_init = 1;
+
+	ret = zxdh_msg_chan_hwlock_init(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +1 -0
index a22ac15065..20ead56e44 100644
@@ -51,6 +51,7 @@ struct zxdh_hw {
 
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t msg_chan_init;
 };
 
 #ifdef __cplusplus
drivers/net/zxdh/zxdh_msg.c new file +161 -0

161 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.27.0
#298 lore raw

Re: [PATCH v9 4/9] net/zxdh: add msg chan and msg hwlock init

Quoted 4 lines · Junlong Wang

Add msg channel and hwlock init implementation.

<...>

Quoted 17 lines

@@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev) if (ret < 0)
         goto err_zxdh_init;

+    ret = zxdh_msg_chan_init();
+    if (ret != 0) {
+        PMD_INIT_LOG(ERR, "Failed to init bar msg chan");
+        goto err_zxdh_init;
+    }
+    hw->msg_chan_init = 1;

drivers/net/zxdh/zxdh_ethdev.c +7 -0
+
+    ret = zxdh_msg_chan_hwlock_init(eth_dev);
+    if (ret != 0) {
+        PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+        goto err_zxdh_init;
+    }
+
Quoted 5 lines

     return ret;

 err_zxdh_init:
+    zxdh_bar_msg_chan_exit();

Should 'zxdh_bar_msg_chan_exit()' called during zxdh_eth_dev_uninit()?

<...>

drivers/net/zxdh/zxdh_msg.c line 47

Quoted 8 lines
drivers/net/zxdh/zxdh_msg.c new file +7 -0
+
+struct zxdh_dev_stat {
+    bool is_mpf_scanned;
+    bool is_res_init;
+    int16_t dev_cnt; /* probe cnt */
+};
+struct zxdh_dev_stat g_dev_stat = {0};

Is there a reason to not make this global variable 'static'? Please remember, when a DPDK application compiled, this will be all application and other driver and libraries, if there is really a good reason, please keep all global variables in the scope of driver.

And no need to initialize global variable to 0, that is done by default.

Quoted 5 lines
drivers/net/zxdh/zxdh_msg.c new file +5 -0
+
+struct zxdh_seqid_item {
+    void *reps_addr;
+    uint16_t id;
+    uint16_t buffer_len;

drivers/net/zxdh/zxdh_msg.c line 62

Quoted 10 lines
drivers/net/zxdh/zxdh_msg.c new file +10 -0
+    uint16_t flag;
+};
+
+struct zxdh_seqid_ring {
+    uint16_t cur_id;
+    rte_spinlock_t lock;
+    struct zxdh_seqid_item reps_info_tbl[ZXDH_BAR_SEQID_NUM_MAX];
+};
+struct zxdh_seqid_ring g_seqid_ring = {0};
+

ditto

<...>

Quoted 24 lines
drivers/net/zxdh/zxdh_msg.c new file +22 -0
+/**
+ * Fun: PF init hard_spinlock addr
+ */
+static int bar_chan_pf_init_spinlock(uint16_t pcie_id, uint64_t bar_base_addr)
+{
+    int lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_RISC);
+
+    zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET,
+            bar_base_addr + ZXDH_HW_LABEL_OFFSET);
+    lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_VF);
+    zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET,
+            bar_base_addr + ZXDH_HW_LABEL_OFFSET);
+    return 0;
+}
+
+int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev)
+{
+    struct zxdh_hw *hw = dev->data->dev_private;
+
+    if (!hw->is_pf)
+        return 0;
+    return bar_chan_pf_init_spinlock(hw->pcie_id, (uint64_t)(hw-
Quoted 1 line

bar_addr[ZXDH_BAR0_INDEX]));

drivers/net/zxdh/zxdh_msg.c line 131

Quoted 3 lines
drivers/net/zxdh/zxdh_msg.c new file +3 -0
+}
+
+static rte_spinlock_t chan_lock;

please move global variables to the top of the file, otherwise it is very easy to miss them.

#299 lore raw

Re:[v9,4/9] net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang
Quoted 5 lines
Quoted 3 lines

err_zxdh_init:
+ zxdh_bar_msg_chan_exit();

Should 'zxdh_bar_msg_chan_exit()' called during zxdh_eth_dev_uninit()?

Yes, it is. I forget it.
I will put it in the zxdh_eth_dev_uninit().

Thanks.

#300 lore raw

PATCH v9 5/9 net/zxdh: add msg chan enable implementation

In reply to Junlong Wang

Add msg chan enable implementation to support
send msg to backend(device side) get infos.

---
 drivers/net/zxdh/zxdh_ethdev.c |   6 +
 drivers/net/zxdh/zxdh_ethdev.h |  12 +
 drivers/net/zxdh/zxdh_msg.c    | 647 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_msg.h    | 131 ++++++-
 4 files changed, 790 insertions(+), 6 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +6 -0
index da454cdff3..21255b2190 100644
@@ -97,6 +97,12 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_msg_chan_enable(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_bar_chan_enable failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +12 -0
index 20ead56e44..7434cc15d7 100644
@@ -28,10 +28,22 @@ extern "C" {
 #define ZXDH_RX_QUEUES_MAX        128U
 #define ZXDH_TX_QUEUES_MAX        128U
 
+union zxdh_virport_num {
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
drivers/net/zxdh/zxdh_msg.c +642 -5

690 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +130 -1

153 lines not on this page · raw message

Signature · 1 line
2.27.0
#301 lore raw

PATCH v9 6/9 net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 250 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_common.h |  30 ++++
 drivers/net/zxdh/zxdh_ethdev.c |  35 +++++
 drivers/net/zxdh/zxdh_ethdev.h |   5 +
 drivers/net/zxdh/zxdh_msg.h    |  21 +++
 6 files changed, 342 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
drivers/net/zxdh/meson.build +1 -0
index 2e0c8fddae..a16db47f89 100644
@@ -17,4 +17,5 @@ sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
         'zxdh_msg.c',
+        'zxdh_common.c',
 )
drivers/net/zxdh/zxdh_common.c new file +250 -0

250 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +30 -0
new file mode 100644
index 0000000000..ba29ca1dad
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_COMMON_H
+#define ZXDH_COMMON_H
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct zxdh_res_para {
+	uint64_t virt_addr;
+	uint16_t pcie_id;
+	uint16_t src_type; /* refer to BAR_DRIVER_TYPE */
+};
+
+int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
+int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZXDH_COMMON_H */
drivers/net/zxdh/zxdh_ethdev.c +35 -0
index 21255b2190..23af69fece 100644
@@ -10,9 +10,21 @@
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
+#include "zxdh_common.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
+{
+	/* epid > 4 is local soft queue. return 1192 */
+	if (v.epid > 4)
+		return 1192;
+	if (v.vf_flag)
+		return v.epid * 256 + v.vfid;
+	else
+		return (v.epid * 8 + v.pfid) + 1152;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -44,6 +56,25 @@ static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 	return ret;
 }
 
+static int zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
+{
+	if (zxdh_phyport_get(eth_dev, &hw->phyport) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get phyport");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+
+	hw->vfid = zxdh_vport_to_vfid(hw->vport);
+
+	if (zxdh_panelid_get(eth_dev, &hw->panel_id) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get panel_id");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+
+	return 0;
+}
+
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
@@ -103,6 +134,10 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_agent_comm(eth_dev, hw);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +5 -0
index 7434cc15d7..7b7bb16be8 100644
@@ -55,6 +55,7 @@ struct zxdh_hw {
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
+	uint16_t vfid;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -64,8 +65,12 @@ struct zxdh_hw {
 	uint8_t duplex;
 	uint8_t is_pf;
 	uint8_t msg_chan_init;
+	uint8_t phyport;
+	uint8_t panel_id;
 };
 
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_msg.h +21 -0
index bbacbbc45e..49a7d23014 100644
@@ -107,6 +107,27 @@ enum ZXDH_BAR_MODULE_ID {
 	ZXDH_BAR_MSG_MODULE_NUM = 100,
 };
 
+enum ZXDH_RES_TBL_FILED {
+	ZXDH_TBL_FIELD_PCIEID     = 0,
+	ZXDH_TBL_FIELD_BDF        = 1,
+	ZXDH_TBL_FIELD_MSGCH      = 2,
+	ZXDH_TBL_FIELD_DATACH     = 3,
+	ZXDH_TBL_FIELD_VPORT      = 4,
+	ZXDH_TBL_FIELD_PNLID      = 5,
+	ZXDH_TBL_FIELD_PHYPORT    = 6,
+	ZXDH_TBL_FIELD_SERDES_NUM = 7,
+	ZXDH_TBL_FIELD_NP_PORT    = 8,
+	ZXDH_TBL_FIELD_SPEED      = 9,
+	ZXDH_TBL_FIELD_HASHID     = 10,
+	ZXDH_TBL_FIELD_NON,
+};
+
+enum ZXDH_TBL_MSG_TYPE {
+	ZXDH_TBL_TYPE_READ,
+	ZXDH_TBL_TYPE_WRITE,
+	ZXDH_TBL_TYPE_NON,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
Signature · 1 line
2.27.0
#302 lore raw

Re: [PATCH v9 6/9] net/zxdh: add zxdh get device backend infos

Quoted 5 lines · Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

<...>

drivers/net/zxdh/zxdh_ethdev.c line 26

Quoted 11 lines
drivers/net/zxdh/zxdh_ethdev.c +10 -0
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
+{
+    /* epid > 4 is local soft queue. return 1192 */
+    if (v.epid > 4)
+        return 1192;
+    if (v.vf_flag)
+        return v.epid * 256 + v.vfid;
+    else
+        return (v.epid * 8 + v.pfid) + 1152;
+}

Is there a reason to not make this function static? This way can get rid of the decleration in the header file.

#303 lore raw

Re: [v9,6/9] net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang
Quoted 6 lines
Quoted 6 lines
drivers/net/zxdh/zxdh_ethdev.c +6 -0
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
+{
+    /* epid > 4 is local soft queue. return 1192 */
+    if (v.epid > 4)
+        return 1192;
+    if (v.vf_flag)
Quoted 8 lines

drivers/net/zxdh/zxdh_ethdev.c line 26

Quoted 5 lines
drivers/net/zxdh/zxdh_ethdev.c +4 -0
+        return v.epid * 256 + v.vfid;
+    else
+        return (v.epid * 8 + v.pfid) + 1152;
+}

Is there a reason to not make this function static? This way can get rid of the decleration in the header file.

In subsequent submission, it will be used by other file functions. Therefore, this function is not set to static.

Thanks!

#304 lore raw

PATCH v9 7/9 net/zxdh: add configure zxdh intr implementation

In reply to Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

---
 drivers/net/zxdh/zxdh_ethdev.c | 301 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |   6 +
 drivers/net/zxdh/zxdh_msg.c    | 188 ++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  16 +-
 drivers/net/zxdh/zxdh_pci.c    |  26 +++
 drivers/net/zxdh/zxdh_pci.h    |  11 ++
 6 files changed, 546 insertions(+), 2 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +301 -0
index 23af69fece..2f8190a428 100644
@@ -11,6 +11,7 @@
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
 #include "zxdh_common.h"
+#include "zxdh_queue.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -25,6 +26,301 @@ uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2 + 1], ZXDH_MSI_NO_VECTOR);
+	}
+}
+
+
+static int32_t zxdh_intr_unmask(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (rte_intr_ack(dev->intr_handle) < 0)
+		return -1;
+
+	hw->use_msix = zxdh_pci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));
+
+	return 0;
+}
+
+static void zxdh_devconf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+
+	if (zxdh_intr_unmask(dev) < 0)
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+}
+
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_fromriscv_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_CTRLCH_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_risc2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_riscvf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_frompfvf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] +
+				ZXDH_MSG_CHAN_PFVFSHARE_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_vf2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_VF, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_pf2vf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_PF, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+static void zxdh_intr_cb_reg(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_register(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_register(tmp, zxdh_frompfvf_intr_handler, dev);
+
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_register(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static void zxdh_intr_cb_unreg(struct rte_eth_dev *dev)
+{
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_unregister(tmp, zxdh_frompfvf_intr_handler, dev);
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_unregister(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static int32_t zxdh_intr_disable(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled)
+		return 0;
+
+	zxdh_intr_cb_unreg(dev);
+	if (rte_intr_disable(dev->intr_handle) < 0)
+		return -1;
+
+	hw->intr_enabled = 0;
+	return 0;
+}
+
+static int32_t zxdh_intr_enable(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled) {
+		zxdh_intr_cb_reg(dev);
+		ret = rte_intr_enable(dev->intr_handle);
+		if (unlikely(ret))
+			PMD_INIT_LOG(ERR, "Failed to enable %s intr", dev->data->name);
+
+		hw->intr_enabled = 1;
+	}
+	return ret;
+}
+
+static int32_t zxdh_intr_release(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		ZXDH_VTPCI_OPS(hw)->set_config_irq(hw, ZXDH_MSI_NO_VECTOR);
+
+	zxdh_queues_unbind_intr(dev);
+	zxdh_intr_disable(dev);
+
+	rte_intr_efd_disable(dev->intr_handle);
+	rte_intr_vec_list_free(dev->intr_handle);
+	rte_free(hw->risc_intr);
+	hw->risc_intr = NULL;
+	rte_free(hw->dtb_intr);
+	hw->dtb_intr = NULL;
+	return 0;
+}
+
+static int32_t zxdh_setup_risc_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint8_t i;
+
+	if (!hw->risc_intr) {
+		PMD_INIT_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) {
+			PMD_INIT_LOG(ERR, "Failed to allocate risc_intr");
+			return -ENOMEM;
+		}
+	}
+
+	for (i = 0; i < ZXDH_MSIX_INTR_MSG_VEC_NUM; i++) {
+		if (dev->intr_handle->efds[i] < 0) {
+			PMD_INIT_LOG(ERR, "[%u]risc interrupt fd is invalid", i);
+			rte_free(hw->risc_intr);
+			hw->risc_intr = NULL;
+			return -1;
+		}
+
+		struct rte_intr_handle *intr_handle = hw->risc_intr + i;
+
+		intr_handle->fd = dev->intr_handle->efds[i];
+		intr_handle->type = dev->intr_handle->type;
+	}
+
+	return 0;
+}
+
+static int32_t zxdh_setup_dtb_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->dtb_intr) {
+		hw->dtb_intr = rte_zmalloc("dtb_intr", sizeof(struct rte_intr_handle), 0);
+		if (hw->dtb_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate dtb_intr");
+			return -ENOMEM;
+		}
+	}
+
+	if (dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1] < 0) {
+		PMD_INIT_LOG(ERR, "[%d]dtb interrupt fd is invalid", ZXDH_MSIX_INTR_DTB_VEC - 1);
+		rte_free(hw->dtb_intr);
+		hw->dtb_intr = NULL;
+		return -1;
+	}
+	hw->dtb_intr->fd = dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1];
+	hw->dtb_intr->type = dev->intr_handle->type;
+	return 0;
+}
+
+static int32_t zxdh_queues_bind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+	uint16_t vec;
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+					i * 2, ZXDH_MSI_NO_VECTOR, vec);
+		}
+	} else {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], i + ZXDH_QUEUE_INTR_VEC_BASE);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set %d, get %d",
+					i * 2, i + ZXDH_QUEUE_INTR_VEC_BASE, vec);
+		}
+	}
+	/* mask all txq intr */
+	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
+		vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+				hw->vqs[(i * 2) + 1], ZXDH_MSI_NO_VECTOR);
+		PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+				(i * 2) + 1, ZXDH_MSI_NO_VECTOR, vec);
+	}
+	return 0;
+}
+
+static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t ret = 0;
+
+	if (!rte_intr_cap_multiple(dev->intr_handle)) {
+		PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
+		return -ENOTSUP;
+	}
+	zxdh_intr_release(dev);
+	uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+	if (dev->data->dev_conf.intr_conf.rxq)
+		nb_efd += dev->data->nb_rx_queues;
+
+	if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+		PMD_INIT_LOG(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+		return -ENOMEM;
+	}
+	PMD_INIT_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle->vec_list_size);
+	if (zxdh_setup_risc_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up rsic_v interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	if (zxdh_setup_dtb_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up dtb interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_queues_bind_intr(dev) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_intr_enable(dev) < 0) {
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	return 0;
+
+free_intr_vec:
+	zxdh_intr_release(dev);
+	return ret;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -138,9 +434,14 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_configure_intr(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_intr_release(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_ethdev.h +6 -0
index 7b7bb16be8..65726f3a20 100644
@@ -7,6 +7,8 @@
 
 #include <rte_ether.h>
 #include "ethdev_driver.h"
+#include <rte_interrupts.h>
+#include <eal_interrupts.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -43,6 +45,9 @@ struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	struct rte_intr_handle *risc_intr;
+	struct rte_intr_handle *dtb_intr;
+	struct zxdh_virtqueue **vqs;
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -59,6 +64,7 @@ struct zxdh_hw {
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
+	uint8_t intr_enabled;
 	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 
drivers/net/zxdh/zxdh_msg.c +188 -0

203 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +14 -2
index 49a7d23014..0d032d306c 100644
@@ -13,10 +13,17 @@
 extern "C" {
 #endif
 
-#define ZXDH_BAR0_INDEX               0
-#define ZXDH_CTRLCH_OFFSET            (0x2000)
+#define ZXDH_BAR0_INDEX                 0
+#define ZXDH_CTRLCH_OFFSET              (0x2000)
+#define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE   1
+#define ZXDH_MSIX_INTR_MSG_VEC_NUM    3
+#define ZXDH_MSIX_INTR_DTB_VEC      (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
+#define ZXDH_MSIX_INTR_DTB_VEC_NUM    1
+#define ZXDH_INTR_NONQUE_NUM        (ZXDH_MSIX_INTR_MSG_VEC_NUM + ZXDH_MSIX_INTR_DTB_VEC_NUM + 1)
+#define ZXDH_QUEUE_INTR_VEC_BASE    (ZXDH_MSIX_INTR_DTB_VEC + ZXDH_MSIX_INTR_DTB_VEC_NUM)
+#define ZXDH_QUEUE_INTR_VEC_NUM       256
 
 #define ZXDH_BAR_MSG_POLLING_SPAN     100
 #define ZXDH_BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / ZXDH_BAR_MSG_POLLING_SPAN)
@@ -202,6 +209,9 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
+					void *reps_buffer, uint16_t *reps_len, void *dev);
+
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
@@ -210,6 +220,8 @@ int zxdh_msg_chan_enable(struct rte_eth_dev *dev);
 int zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in,
 			struct zxdh_msg_recviver_mem *result);
 
+int zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_pci.c +26 -0
index a88d620f30..65164c86b7 100644
@@ -92,6 +92,24 @@ static void zxdh_set_features(struct zxdh_hw *hw, uint64_t features)
 	rte_write32(features >> 32, &hw->common_cfg->guest_feature);
 }
 
+static uint16_t zxdh_set_config_irq(struct zxdh_hw *hw, uint16_t vec)
+{
+	rte_write16(vec, &hw->common_cfg->msix_config);
+	return rte_read16(&hw->common_cfg->msix_config);
+}
+
+static uint16_t zxdh_set_queue_irq(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec)
+{
+	rte_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
+	rte_write16(vec, &hw->common_cfg->queue_msix_vector);
+	return rte_read16(&hw->common_cfg->queue_msix_vector);
+}
+
+static uint8_t zxdh_get_isr(struct zxdh_hw *hw)
+{
+	return rte_read8(hw->isr);
+}
+
 const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.read_dev_cfg   = zxdh_read_dev_config,
 	.write_dev_cfg  = zxdh_write_dev_config,
@@ -99,8 +117,16 @@ const struct zxdh_pci_ops zxdh_dev_pci_ops = {
 	.set_status     = zxdh_set_status,
 	.get_features   = zxdh_get_features,
 	.set_features   = zxdh_set_features,
+	.set_queue_irq  = zxdh_set_queue_irq,
+	.set_config_irq = zxdh_set_config_irq,
+	.get_isr        = zxdh_get_isr,
 };
 
+uint8_t zxdh_pci_isr(struct zxdh_hw *hw)
+{
+	return ZXDH_VTPCI_OPS(hw)->get_isr(hw);
+}
+
 uint16_t zxdh_pci_get_features(struct zxdh_hw *hw)
 {
 	return ZXDH_VTPCI_OPS(hw)->get_features(hw);
drivers/net/zxdh/zxdh_pci.h +11 -0
index ff656f28e6..f362658ba6 100644
@@ -22,6 +22,13 @@ enum zxdh_msix_status {
 	ZXDH_MSIX_ENABLED  = 2
 };
 
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define ZXDH_PCI_ISR_INTR    0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define ZXDH_PCI_ISR_CONFIG  0x2
+/* Vector value used to disable MSI for queue. */
+#define ZXDH_MSI_NO_VECTOR   0x7F
+
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
@@ -110,6 +117,9 @@ struct zxdh_pci_ops {
 
 	uint64_t (*get_features)(struct zxdh_hw *hw);
 	void     (*set_features)(struct zxdh_hw *hw, uint64_t features);
+	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
+	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
+	uint8_t  (*get_isr)(struct zxdh_hw *hw);
 };
 
 struct zxdh_hw_internal {
@@ -130,6 +140,7 @@ int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 
 uint16_t zxdh_pci_get_features(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_pci_msix_detect(struct rte_pci_device *dev);
+uint8_t zxdh_pci_isr(struct zxdh_hw *hw);
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.27.0
#305 lore raw

Re: [PATCH v9 7/9] net/zxdh: add configure zxdh intr implementation

Quoted 4 lines · Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

<...>

Quoted 41 lines
drivers/net/zxdh/zxdh_ethdev.c +27 -0
+static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+    struct zxdh_hw *hw = dev->data->dev_private;
+    int32_t ret = 0;
+
+    if (!rte_intr_cap_multiple(dev->intr_handle)) {
+        PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
+        return -ENOTSUP;
+    }
+    zxdh_intr_release(dev);
+    uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+    if (dev->data->dev_conf.intr_conf.rxq)
+        nb_efd += dev->data->nb_rx_queues;
+
+    if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+        PMD_INIT_LOG(ERR, "Fail to create eventfd");
+        return -1;
+    }
+
+    if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+                    hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+        PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+                    hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+        return -ENOMEM;
+    }
+    PMD_INIT_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle-
Quoted 1 line

vec_list_size);

+    if (zxdh_setup_risc_interrupts(dev) != 0) {
+        PMD_INIT_LOG(ERR, "Error setting up rsic_v interrupts!"); +        ret = -1;
+        goto free_intr_vec;
+    }
+    if (zxdh_setup_dtb_interrupts(dev) != 0) {
+        PMD_INIT_LOG(ERR, "Error setting up dtb interrupts!"); +        ret = -1;
+        goto free_intr_vec;
+    }

drivers/net/zxdh/zxdh_ethdev.c +2 -0
+
+    if (zxdh_queues_bind_intr(dev) < 0) {

drivers/net/zxdh/zxdh_ethdev.c uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v) · line 316

Quoted 10 lines
drivers/net/zxdh/zxdh_ethdev.c +10 -0
+        PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+        ret = -1;
+        goto free_intr_vec;
+    }
+
+    if (zxdh_intr_enable(dev) < 0) {
+        PMD_DRV_LOG(ERR, "interrupt enable failed");
+        ret = -1;
+        goto free_intr_vec;
+    }

One of the above log use 'PMD_INIT_LOG()' and other 'PMD_DRV_LOG()', how do you diffrentiate?
Do you really need two different log type, init and driver? (I understand need for others, Rx, Tx & msg, but still less is easier)

#306 lore raw

PATCH v9 8/9 net/zxdh: add zxdh dev infos get ops

In reply to Junlong Wang

Add support for zxdh infos get.

---
 drivers/net/zxdh/zxdh_ethdev.c | 44 +++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_ethdev.h |  2 ++
 2 files changed, 45 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +43 -1
index 2f8190a428..bbdbda3457 100644
@@ -26,6 +26,43 @@ uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static int32_t zxdh_dev_infos_get(struct rte_eth_dev *dev,
+					struct rte_eth_dev_info *dev_info)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	dev_info->speed_capa       = rte_eth_speed_bitflag(hw->speed, RTE_ETH_LINK_FULL_DUPLEX);
+	dev_info->max_rx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_RX_QUEUES_MAX);
+	dev_info->max_tx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_TX_QUEUES_MAX);
+	dev_info->min_rx_bufsize   = ZXDH_MIN_RX_BUFSIZE;
+	dev_info->max_rx_pktlen    = ZXDH_MAX_RX_PKTLEN;
+	dev_info->max_mac_addrs    = ZXDH_MAX_MAC_ADDRS;
+	dev_info->rx_offload_capa  = (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+					RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
+					RTE_ETH_RX_OFFLOAD_QINQ_STRIP);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_SCATTER);
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_TCP_LRO;
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	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);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
+					RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+					RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM);
+
+	return 0;
+}
+
 static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
@@ -321,6 +358,11 @@ static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+	.dev_infos_get			 = zxdh_dev_infos_get,
+};
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -377,7 +419,7 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
 	int ret = 0;
 
-	eth_dev->dev_ops = NULL;
+	eth_dev->dev_ops = &zxdh_eth_dev_ops;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
drivers/net/zxdh/zxdh_ethdev.h +2 -0
index 65726f3a20..89c5a9bb5f 100644
@@ -29,6 +29,8 @@ extern "C" {
 #define ZXDH_NUM_BARS             2
 #define ZXDH_RX_QUEUES_MAX        128U
 #define ZXDH_TX_QUEUES_MAX        128U
+#define ZXDH_MIN_RX_BUFSIZE       64
+#define ZXDH_MAX_RX_PKTLEN        14000U
 
 union zxdh_virport_num {
 	uint16_t vport;
Signature · 1 line
2.27.0
#307 lore raw

PATCH v9 9/9 net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 135 ++++++++++
 drivers/net/zxdh/zxdh_common.h |  12 +
 drivers/net/zxdh/zxdh_ethdev.c | 449 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |  16 ++
 drivers/net/zxdh/zxdh_pci.c    |  98 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  26 ++
 drivers/net/zxdh/zxdh_queue.c  | 123 +++++++++
 drivers/net/zxdh/zxdh_queue.h  | 172 +++++++++++++
 9 files changed, 1032 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
drivers/net/zxdh/meson.build +1 -0
index a16db47f89..b96aa5a27e 100644
@@ -18,4 +18,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_msg.c',
         'zxdh_common.c',
+        'zxdh_queue.c',
 )
drivers/net/zxdh/zxdh_common.c +135 -0

144 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h +12 -0
index ba29ca1dad..a26f0d8d6f 100644
@@ -14,6 +14,10 @@
 extern "C" {
 #endif
 
+#define ZXDH_VF_LOCK_REG               0x90
+#define ZXDH_VF_LOCK_ENABLE_MASK       0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX   10
+
 struct zxdh_res_para {
 	uint64_t virt_addr;
 	uint16_t pcie_id;
@@ -23,6 +27,14 @@ struct zxdh_res_para {
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_panelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
 
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+void zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_timedlock(struct zxdh_hw *hw, uint32_t us);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+int32_t zxdh_datach_set(struct rte_eth_dev *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_ethdev.c +449 -0

457 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +16 -0
index 89c5a9bb5f..28e78b0086 100644
@@ -31,6 +31,13 @@ extern "C" {
 #define ZXDH_TX_QUEUES_MAX        128U
 #define ZXDH_MIN_RX_BUFSIZE       64
 #define ZXDH_MAX_RX_PKTLEN        14000U
+#define ZXDH_QUEUE_DEPTH          1024
+#define ZXDH_QUEUES_BASE          0
+#define ZXDH_TOTAL_QUEUES_NUM     4096
+#define ZXDH_QUEUES_NUM_MAX       256
+#define ZXDH_QUERES_SHARE_BASE    (0x5000)
+
+#define ZXDH_MBUF_BURST_SZ        64
 
 union zxdh_virport_num {
 	uint16_t vport;
@@ -43,6 +50,11 @@ union zxdh_virport_num {
 	};
 };
 
+struct zxdh_chnl_context {
+	uint16_t valid;
+	uint16_t ph_chno;
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
@@ -50,6 +62,7 @@ struct zxdh_hw {
 	struct rte_intr_handle *risc_intr;
 	struct rte_intr_handle *dtb_intr;
 	struct zxdh_virtqueue **vqs;
+	struct zxdh_chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -63,6 +76,7 @@ struct zxdh_hw {
 	uint16_t device_id;
 	uint16_t port_id;
 	uint16_t vfid;
+	uint16_t queue_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -75,6 +89,8 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t has_tx_offload;
+	uint8_t has_rx_offload;
 };
 
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
drivers/net/zxdh/zxdh_pci.c +98 -0

116 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +26 -0
index f362658ba6..e86667357b 100644
@@ -29,7 +29,20 @@ enum zxdh_msix_status {
 /* Vector value used to disable MSI for queue. */
 #define ZXDH_MSI_NO_VECTOR   0x7F
 
+#define ZXDH_PCI_VRING_ALIGN         4096
+
+#define ZXDH_NET_F_CSUM              0   /* Host handles pkts w/ partial csum */
+#define ZXDH_NET_F_GUEST_CSUM        1   /* Guest handles pkts w/ partial csum */
+#define ZXDH_NET_F_MTU               3   /* Initial MTU advice. */
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
+#define ZXDH_NET_F_GUEST_TSO4        7   /* Guest can handle TSOv4 in. */
+#define ZXDH_NET_F_GUEST_TSO6        8   /* Guest can handle TSOv6 in. */
+#define ZXDH_NET_F_GUEST_ECN         9   /* Guest can handle TSO[6] w/ ECN in. */
+#define ZXDH_NET_F_GUEST_UFO         10  /* Guest can handle UFO in. */
+
+#define ZXDH_NET_F_HOST_UFO          14  /* Host can handle UFO in. */
+#define ZXDH_NET_F_HOST_TSO4         11  /* Host can handle TSOv4 in. */
+#define ZXDH_NET_F_HOST_TSO6         12  /* Host can handle TSOv6 in. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
 #define ZXDH_NET_F_MQ                22  /* Device supports Receive Flow Steering */
@@ -53,6 +66,7 @@ enum zxdh_msix_status {
 #define ZXDH_CONFIG_STATUS_FEATURES_OK     0x08
 #define ZXDH_CONFIG_STATUS_DEV_NEED_RESET  0x40
 #define ZXDH_CONFIG_STATUS_FAILED          0x80
+#define ZXDH_PCI_QUEUE_ADDR_SHIFT          12
 
 struct zxdh_net_config {
 	/* The config defining mac address (if ZXDH_NET_F_MAC) */
@@ -108,6 +122,11 @@ static inline int32_t vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int32_t vtpci_packed_queue(struct zxdh_hw *hw)
+{
+	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+}
+
 struct zxdh_pci_ops {
 	void     (*read_dev_cfg)(struct zxdh_hw *hw, size_t offset, void *dst, int32_t len);
 	void     (*write_dev_cfg)(struct zxdh_hw *hw, size_t offset, const void *src, int32_t len);
@@ -120,6 +139,11 @@ struct zxdh_pci_ops {
 	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
 	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
 	uint8_t  (*get_isr)(struct zxdh_hw *hw);
+	uint16_t (*get_queue_num)(struct zxdh_hw *hw, uint16_t queue_id);
+	void     (*set_queue_num)(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size);
+
+	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
@@ -141,6 +165,8 @@ int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 uint16_t zxdh_pci_get_features(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_pci_msix_detect(struct rte_pci_device *dev);
 uint8_t zxdh_pci_isr(struct zxdh_hw *hw);
+void zxdh_pci_reinit_complete(struct zxdh_hw *hw);
+void zxdh_pci_set_status(struct zxdh_hw *hw, uint8_t status);
 
 #ifdef __cplusplus
 }
drivers/net/zxdh/zxdh_queue.c new file +123 -0

123 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +172 -0

195 lines not on this page · raw message

Signature · 1 line
2.27.0
#308 lore raw

Re: [PATCH v9 0/9] net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 28 lines · Junlong Wang

v9:
  - fix 'v8 3/9' patch use PCI bus API,
    and common PCI constants according to David Marchand's comments.

v8:
  - fix flexible arrays、Waddress-of-packed-member error. - all structs、enum、define ,etc use zxdh/ZXDH_ prefixed. - use zxdh_try/release_lock,and move loop into zxdh_timedlock, make hardware lock follow spinlock pattern.

v7:
  - add release notes and modify zxdh.rst issues. - avoid use pthread and use rte_spinlock_lock. - using the prefix ZXDH_ before some definitions. - resole issues according to thomas's comments.

v6:
  - Resolve ci/intel compilation issues.
  - fix meson.build indentation in earlier patch.

V5:
  - split driver into multiple patches,part of the zxdh driver, later provide dev start/stop,queue_setup,npsdk_init,mac,vlan,rss ,etc. - fix errors reported by scripts.
  - move the product link in zxdh.rst.
  - fix meson check use RTE_ARCH_X86_64/RTE_ARCH_ARM64.
  - modify other comments according to Ferruh's comments.

Quoted 11 lines

Junlong Wang (9):
  net/zxdh: add zxdh ethdev pmd driver net/zxdh: add logging implementation net/zxdh: add zxdh device pci init implementation net/zxdh: add msg chan and msg hwlock init net/zxdh: add msg chan enable implementation net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

#309 lore raw

v9 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 14 lines
Quoted 5 lines

net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 7 lines

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Hi Ferruh,
The complete driver function has been implemented. At present, the driver function is integrated in batches.
The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

#310 lore raw

Re: [PATCH v9 0/9] net/zxdh: introduce net zxdh driver

Quoted 22 lines · Junlong Wang
Quoted 14 lines
Quoted 5 lines

   net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

 Hi Junlong,

 I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

 What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 7 lines

 And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

 As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Quoted 5 lines

Hi Ferruh,
      The complete driver function has been implemented. At present, the driver function is integrated in batches.
      The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

Sounds good, thanks.

Btw, build should be fine after each patch, but in this patch series there are warnings in some early patches, can you please fix them in next version?

@Aaron, @David, what do you think to add patch by patch build to the CI? I hit the same issue in multiple series in this release.

#311 lore raw

Re: [PATCH v9 0/9] net/zxdh: introduce net zxdh driver

Quoted 33 lines · Ferruh Yigit
Quoted 22 lines · Junlong Wang
Quoted 14 lines
Quoted 5 lines

net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 7 lines

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Quoted 5 lines

Hi Ferruh,
The complete driver function has been implemented. At present, the driver function is integrated in batches.
The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

Sounds good, thanks.

Quoted 6 lines

Btw, build should be fine after each patch, but in this patch series there are warnings in some early patches, can you please fix them in next version?

@Aaron, @David, what do you think to add patch by patch build to the CI? I hit the same issue in multiple series in this release.

I would love to have patch by patch tests too, but I don't think UNH can handle such load.
We could limit at doing this patch by patch in GHA / ovsrobot only (which I think it is done for OVS CI).

Signature · 1 line
David Marchand
#312 lore raw

v9 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 31 lines
Quoted 22 lines
Quoted 14 lines
Quoted 5 lines

net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 7 lines

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Quoted 5 lines

Hi Ferruh,
The complete driver function has been implemented. At present, the driver function is integrated in batches.
The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

Sounds good, thanks.

Quoted 6 lines

Btw, build should be fine after each patch, but in this patch series there are warnings in some early patches, can you please fix them in next version?

@Aaron, @David, what do you think to add patch by patch build to the CI? I hit the same issue in multiple series in this release.

Sure. But I cannot see these Warnings in the [v9] net/zxdh CI/check Description. What do I need to do to see these Warnings?

Thanks.

#313 lore raw

Re: [PATCH v9 0/9] net/zxdh: introduce net zxdh driver

04/11/2024 12:46, Junlong Wang:

Quoted 35 lines
Quoted 35 lines
Quoted 22 lines
Quoted 14 lines
Quoted 5 lines

net/zxdh: add zxdh get device backend infos net/zxdh: add configure zxdh intr implementation net/zxdh: add zxdh dev infos get ops net/zxdh: add zxdh dev configure ops

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 7 lines

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Quoted 5 lines

Hi Ferruh,
The complete driver function has been implemented. At present, the driver function is integrated in batches.
The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

Sounds good, thanks.

Btw, build should be fine after each patch, but in this patch series there are warnings in some early patches, can you please fix them in next version?

Quoted 5 lines
Quoted 2 lines

@Aaron, @David, what do you think to add patch by patch build to the CI? I hit the same issue in multiple series in this release.

Sure. But I cannot see these Warnings in the [v9] net/zxdh CI/check Description. What do I need to do to see these Warnings?

You need to test compilation after each patch locally. You can use "git rebase -i --exec ninja" for instance.

#314 lore raw

v9 cover net/zxdh: introduce net zxdh driver

In reply to Junlong Wang
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 16 lines
Quoted 8 lines

Hi Junlong,

I can see not all of the eth_dev_ops implemented, and datapath not implemented, so driver is not functional right now.

What happens if you want to run testpmd with the current state of the driver, I assume it crashes?

Quoted 8 lines

And what is the plan for the driver? Are you planning to upstream remaining support in this release or in future releases?

As the driver is not functional yet, to set the expectation right for the users, I suggest marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update, what do you think?

Quoted 5 lines

Hi Ferruh,
The complete driver function has been implemented. At present, the driver function is integrated in batches.
The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. Thanks.

Sounds good, thanks.

Btw, build should be fine after each patch, but in this patch series there are warnings in some early patches, can you please fix them in next version?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

@Aaron, @David, what do you think to add patch by patch build to the CI? I hit the same issue in multiple series in this release.

Sure. But I cannot see these Warnings in the [v9] net/zxdh CI/check Description. What do I need to do to see these Warnings?

You need to test compilation after each patch locally. You can use "git rebase -i --exec ninja" for instance.

Sorry, I have tried multiple times to use 'git rebase -i --exec ninja' locally after each patch, but I couldn't find the warnings. I have no idea how to solve it. Is there any other way to see the warnings?

#315 lore raw

Re: [PATCH v9 0/9] net/zxdh: introduce net zxdh driver

Quoted 34 lines · Junlong Wang
Quoted 25 lines

 > > >> Hi Junlong,
 > > >
 > > >> I can see not all of the eth_dev_ops implemented, and datapath not
 > > >> implemented, so driver is not functional right now.
 > > >
 > > >> What happens if you want to run testpmd with the current state of the
 > > >> driver, I assume it crashes?
 > > >
 > > >> And what is the plan for the driver? Are you planning to upstream
 > > >> remaining support in this release or in future releases?
 > > >
 > > >> As the driver is not functional yet, to set the expectation right for
 > > >> the users, I suggest marking driver as experimental in the maintainers
 > > >> file and document the restrictions in the driver documentation, also
 > > >> clarify this in the release notes update, what do you think?
 > > > >
 > > > Hi Ferruh,
 > > >       The complete driver function has been implemented. At present, the driver function is integrated in batches.
 > > >       The integrated PMD does not cause the crash but cannot support all PMD functions.We plan to integrate the driver in this version and finally provide a complete and available driver. > > >       In the current phase, we will marking driver as experimental in the maintainers file and document the restrictions in the driver documentation, also clarify this in the release notes update. > > >       Thanks.
 > >
 > > Sounds good, thanks.
 > >
 > >

Quoted 8 lines

 > > Btw, build should be fine after each patch, but in this patch series > > there are warnings in some early patches, can you please fix them in > > next version?
 > >
 > > @Aaron, @David, what do you think to add patch by patch build to the CI? > > I hit the same issue in multiple series in this release.
 >
 > Sure. But I cannot see these Warnings in the [v9] net/zxdh CI/

check Description.

Quoted 9 lines
Quoted 4 lines

 > What do I need to do to see these Warnings?

 You need to test compilation after each patch locally. You can use "git rebase -i --exec ninja" for instance.

Sorry, I have tried multiple times to use 'git rebase -i -- exec ninja' locally after each patch, but I couldn't find the warnings. I have no idea how to solve it. Is there any other way to see the warnings?

Hi Junlong,

I can't reproduce it, and v10 also looks good, so I will proceed with the driver.

From my logs I can see patch by path fails in 'net/r8169', not this driver, probably I confused them as I reviewed them next to each other, sorry about confusion caused.

#316 lore raw

PATCH v8 2/9 net/zxdh: add logging implementation

In reply to Junlong Wang

Add zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 15 +++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 40 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +13 -2
index 5b6c9ec1bf..c911284423 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -19,13 +20,18 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_INIT_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -90,3 +96,8 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +40 -0
new file mode 100644
index 0000000000..a8a6a3135b
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_LOGS_H
+#define ZXDH_LOGS_H
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_init;
+#define RTE_LOGTYPE_ZXDH_INIT zxdh_logtype_init
+#define PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_INIT, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_rx;
+#define RTE_LOGTYPE_ZXDH_RX zxdh_logtype_rx
+#define PMD_RX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_RX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_tx;
+#define RTE_LOGTYPE_ZXDH_TX zxdh_logtype_tx
+#define PMD_TX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_TX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_msg;
+#define RTE_LOGTYPE_ZXDH_MSG zxdh_logtype_msg
+#define PMD_MSG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_MSG, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+#endif /* ZXDH_LOGS_H */
Signature · 1 line
2.27.0
#317 lore raw

PATCH v8 3/9 net/zxdh: add zxdh device pci init implementation

In reply to Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  43 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  21 ++-
 drivers/net/zxdh/zxdh_pci.c    | 285 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 151 +++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 105 ++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  51 ++++++
 7 files changed, 655 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/meson.build +1 -0
index 932fb1c835..7db4e7bc71 100644
@@ -15,4 +15,5 @@ endif
 
 sources = files(
         'zxdh_ethdev.c',
+        'zxdh_pci.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +43 -0

55 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +19 -2
index 93375aea11..8be5af6aeb 100644
@@ -5,6 +5,8 @@
 #ifndef ZXDH_ETHDEV_H
 #define ZXDH_ETHDEV_H
 
+#include <rte_ether.h>
+
 #include "ethdev_driver.h"
 
 #ifdef __cplusplus
@@ -24,15 +26,30 @@ extern "C" {
 #define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
 #define ZXDH_NUM_BARS          2
+#define ZXDH_RX_QUEUES_MAX     128U
+#define ZXDH_TX_QUEUES_MAX     128U
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
-	uint32_t  speed;
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
+	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +285 -0

285 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +151 -0

151 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +105 -0

105 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.27.0
#318 lore raw

Re: [PATCH v8 3/9] net/zxdh: add zxdh device pci init implementation

Quoted 3 lines · Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

This title with PCI intrigued me, so I had a look at this patch.

Please use the PCI bus API and don't redefine common PCI constants/helpers. To make it easier for you, I recommend having a look at:

$ git show a10b6e53fe baa9c55009 7bb1168d98 -- drivers/net/virtio/virtio_pci.c
Signature · 1 line
David Marchand
#319 lore raw

PATCH v8 4/9 net/zxdh: add msg chan and msg hwlock init

In reply to Junlong Wang

Add msg channel and hwlock init implementation.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  15 +++
 drivers/net/zxdh/zxdh_ethdev.h |   1 +
 drivers/net/zxdh/zxdh_msg.c    | 161 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  67 ++++++++++++++
 5 files changed, 245 insertions(+)
 create mode 100644 drivers/net/zxdh/zxdh_msg.c
 create mode 100644 drivers/net/zxdh/zxdh_msg.h
drivers/net/zxdh/meson.build +1 -0
index 7db4e7bc71..2e0c8fddae 100644
@@ -16,4 +16,5 @@ endif
 sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
+        'zxdh_msg.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +15 -0
index 8877855965..2dcf144fc9 100644
@@ -9,6 +9,7 @@
 #include "zxdh_ethdev.h"
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
+#include "zxdh_msg.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
@@ -83,9 +84,23 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret < 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_msg_chan_init();
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init bar msg chan");
+		goto err_zxdh_init;
+	}
+	hw->msg_chan_init = 1;
+
+	ret = zxdh_msg_chan_hwlock_init(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_chan_hwlock_init failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 	return ret;
drivers/net/zxdh/zxdh_ethdev.h +1 -0
index 8be5af6aeb..5902704923 100644
@@ -52,6 +52,7 @@ struct zxdh_hw {
 
 	uint8_t duplex;
 	uint8_t is_pf;
+	uint8_t msg_chan_init;
 };
 
 #ifdef __cplusplus
drivers/net/zxdh/zxdh_msg.c new file +161 -0

161 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.27.0
#320 lore raw

PATCH v8 5/9 net/zxdh: add msg chan enable implementation

In reply to Junlong Wang

Add msg chan enable implementation to support
send msg to backend(device side) get infos.

---
 drivers/net/zxdh/zxdh_ethdev.c |   6 +
 drivers/net/zxdh/zxdh_ethdev.h |  12 +
 drivers/net/zxdh/zxdh_msg.c    | 641 ++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_msg.h    | 129 +++++++
 4 files changed, 785 insertions(+), 3 deletions(-)
drivers/net/zxdh/zxdh_ethdev.c +6 -0
index 2dcf144fc9..a729344288 100644
@@ -97,6 +97,12 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_msg_chan_enable(eth_dev);
+	if (ret != 0) {
+		PMD_INIT_LOG(ERR, "zxdh_msg_bar_chan_enable failed ret %d", ret);
+		goto err_zxdh_init;
+	}
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +12 -0
index 5902704923..bed1334690 100644
@@ -29,10 +29,22 @@ extern "C" {
 #define ZXDH_RX_QUEUES_MAX     128U
 #define ZXDH_TX_QUEUES_MAX     128U
 
+union zxdh_virport_num {
+	uint16_t vport;
+	struct {
+		uint16_t vfid:8;
+		uint16_t pfid:3;
+		uint16_t vf_flag:1;
+		uint16_t epid:3;
+		uint16_t direct_flag:1;
+	};
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
 	uint64_t host_features;
drivers/net/zxdh/zxdh_msg.c +638 -3

675 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +129 -0

151 lines not on this page · raw message

Signature · 1 line
2.27.0
#321 lore raw

PATCH v8 6/9 net/zxdh: add zxdh get device backend infos

In reply to Junlong Wang

Add zxdh get device backend infos,
use msg chan to send msg get.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 250 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_common.h |  30 ++++
 drivers/net/zxdh/zxdh_ethdev.c |  35 +++++
 drivers/net/zxdh/zxdh_ethdev.h |   5 +
 drivers/net/zxdh/zxdh_msg.c    |  17 +--
 drivers/net/zxdh/zxdh_msg.h    |  21 +++
 drivers/net/zxdh/zxdh_queue.h  |   4 +
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +
 9 files changed, 359 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_common.c
 create mode 100644 drivers/net/zxdh/zxdh_common.h
drivers/net/zxdh/meson.build +1 -0
index 2e0c8fddae..a16db47f89 100644
@@ -17,4 +17,5 @@ sources = files(
         'zxdh_ethdev.c',
         'zxdh_pci.c',
         'zxdh_msg.c',
+        'zxdh_common.c',
 )
drivers/net/zxdh/zxdh_common.c new file +250 -0

250 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h new file +30 -0
new file mode 100644
index 0000000000..f098ae4cf9
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_COMMON_H
+#define ZXDH_COMMON_H
+
+#include <stdint.h>
+#include <rte_ethdev.h>
+
+#include "zxdh_ethdev.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct zxdh_res_para {
+	uint64_t virt_addr;
+	uint16_t pcie_id;
+	uint16_t src_type; /* refer to BAR_DRIVER_TYPE */
+};
+
+int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
+int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZXDH_COMMON_H */
drivers/net/zxdh/zxdh_ethdev.c +35 -0
index a729344288..8d9df218ce 100644
@@ -10,9 +10,21 @@
 #include "zxdh_logs.h"
 #include "zxdh_pci.h"
 #include "zxdh_msg.h"
+#include "zxdh_common.h"
 
 struct zxdh_hw_internal zxdh_hw_internal[RTE_MAX_ETHPORTS];
 
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
+{
+	/* epid > 4 is local soft queue. return 1192 */
+	if (v.epid > 4)
+		return 1192;
+	if (v.vf_flag)
+		return v.epid * 256 + v.vfid;
+	else
+		return (v.epid * 8 + v.pfid) + 1152;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -44,6 +56,25 @@ static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 	return ret;
 }
 
+static int zxdh_agent_comm(struct rte_eth_dev *eth_dev, struct zxdh_hw *hw)
+{
+	if (zxdh_phyport_get(eth_dev, &hw->phyport) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get phyport");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get phyport success: 0x%x", hw->phyport);
+
+	hw->vfid = zxdh_vport_to_vfid(hw->vport);
+
+	if (zxdh_pannelid_get(eth_dev, &hw->panel_id) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to get panel_id");
+		return -1;
+	}
+	PMD_INIT_LOG(INFO, "Get panel id success: 0x%x", hw->panel_id);
+
+	return 0;
+}
+
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
@@ -103,6 +134,10 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 		goto err_zxdh_init;
 	}
 
+	ret = zxdh_agent_comm(eth_dev, hw);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
drivers/net/zxdh/zxdh_ethdev.h +5 -0
index bed1334690..1ee8dd744c 100644
@@ -56,6 +56,7 @@ struct zxdh_hw {
 	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
+	uint16_t vfid;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -65,8 +66,12 @@ struct zxdh_hw {
 	uint8_t duplex;
 	uint8_t is_pf;
 	uint8_t msg_chan_init;
+	uint8_t phyport;
+	uint8_t panel_id;
 };
 
+uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_msg.c +9 -8
index 1bf72a9b7c..4105daf5c6 100644
@@ -133,7 +133,9 @@ struct zxdh_seqid_ring {
 };
 struct zxdh_seqid_ring g_seqid_ring = {0};
 
-static uint16_t pcie_id_to_hard_lock(uint16_t src_pcieid, uint8_t dst)
+static uint8_t tmp_msg_header[ZXDH_BAR_MSG_ADDR_CHAN_INTERVAL];
+
+static uint16_t zxdh_pcie_id_to_hard_lock(uint16_t src_pcieid, uint8_t dst)
 {
 	uint16_t lock_id = 0;
 	uint16_t pf_idx = (src_pcieid & ZXDH_PCIEID_PF_IDX_MASK) >> ZXDH_PCIEID_PF_IDX_OFFSET;
@@ -209,11 +211,11 @@ static int32_t zxdh_spinlock_unlock(uint32_t virt_lock_id, uint64_t virt_addr, u
  */
 static int bar_chan_pf_init_spinlock(uint16_t pcie_id, uint64_t bar_base_addr)
 {
-	int lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_RISC);
+	int lock_id = zxdh_pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_RISC);
 
 	zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET,
 			bar_base_addr + ZXDH_HW_LABEL_OFFSET);
-	lock_id = pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_VF);
+	lock_id = zxdh_pcie_id_to_hard_lock(pcie_id, ZXDH_MSG_CHAN_END_VF);
 	zxdh_spinlock_unlock(lock_id, bar_base_addr + ZXDH_BAR0_SPINLOCK_OFFSET,
 			bar_base_addr + ZXDH_HW_LABEL_OFFSET);
 	return 0;
@@ -409,7 +411,7 @@ static uint16_t zxdh_bar_chan_subchan_addr_get(struct zxdh_pci_bar_msg *in, uint
 static int zxdh_bar_hard_lock(uint16_t src_pcieid, uint8_t dst, uint64_t virt_addr)
 {
 	int ret = 0;
-	uint16_t lockid = pcie_id_to_hard_lock(src_pcieid, dst);
+	uint16_t lockid = zxdh_pcie_id_to_hard_lock(src_pcieid, dst);
 
 	PMD_MSG_LOG(DEBUG, "dev pcieid: 0x%x lock, get hardlockid: %u", src_pcieid, lockid);
 	if (dst == ZXDH_MSG_CHAN_END_RISC)
@@ -426,7 +428,7 @@ static int zxdh_bar_hard_lock(uint16_t src_pcieid, uint8_t dst, uint64_t virt_ad
 
 static void zxdh_bar_hard_unlock(uint16_t src_pcieid, uint8_t dst, uint64_t virt_addr)
 {
-	uint16_t lockid = pcie_id_to_hard_lock(src_pcieid, dst);
+	uint16_t lockid = zxdh_pcie_id_to_hard_lock(src_pcieid, dst);
 
 	PMD_MSG_LOG(DEBUG, "dev pcieid: 0x%x unlock, get hardlockid: %u", src_pcieid, lockid);
 	if (dst == ZXDH_MSG_CHAN_END_RISC)
@@ -586,7 +588,6 @@ static uint16_t zxdh_bar_chan_msg_valid_set(uint64_t subchan_addr, uint8_t valid
 	return ZXDH_BAR_MSG_OK;
 }
 
-static uint8_t temp_msg[ZXDH_BAR_MSG_ADDR_CHAN_INTERVAL];
 static uint16_t zxdh_bar_chan_msg_send(uint64_t subchan_addr,
 					void *payload_addr,
 					uint16_t payload_len,
@@ -596,13 +597,13 @@ static uint16_t zxdh_bar_chan_msg_send(uint64_t subchan_addr,
 	ret = zxdh_bar_chan_msg_header_set(subchan_addr, msg_header);
 
 	ret = zxdh_bar_chan_msg_header_get(subchan_addr,
-				(struct zxdh_bar_msg_header *)temp_msg);
+				(struct zxdh_bar_msg_header *)tmp_msg_header);
 
 	ret = zxdh_bar_chan_msg_payload_set(subchan_addr,
 				(uint8_t *)(payload_addr), payload_len);
 
 	ret = zxdh_bar_chan_msg_payload_get(subchan_addr,
-				temp_msg, payload_len);
+				tmp_msg_header, payload_len);
 
 	ret = zxdh_bar_chan_msg_valid_set(subchan_addr, ZXDH_BAR_MSG_CHAN_USED);
 	return ret;
drivers/net/zxdh/zxdh_msg.h +21 -0
index 7fbab4b214..7da60ee189 100644
@@ -107,6 +107,27 @@ enum zxdh_bar_module_id {
 	ZXDH_BAR_MSG_MODULE_NUM = 100,
 };
 
+enum ZXDH_RES_TBL_FILED {
+	ZXDH_TBL_FIELD_PCIEID     = 0,
+	ZXDH_TBL_FIELD_BDF        = 1,
+	ZXDH_TBL_FIELD_MSGCH      = 2,
+	ZXDH_TBL_FIELD_DATACH     = 3,
+	ZXDH_TBL_FIELD_VPORT      = 4,
+	ZXDH_TBL_FIELD_PNLID      = 5,
+	ZXDH_TBL_FIELD_PHYPORT    = 6,
+	ZXDH_TBL_FIELD_SERDES_NUM = 7,
+	ZXDH_TBL_FIELD_NP_PORT    = 8,
+	ZXDH_TBL_FIELD_SPEED      = 9,
+	ZXDH_TBL_FIELD_HASHID     = 10,
+	ZXDH_TBL_FIELD_NON,
+};
+
+enum ZXDH_TBL_MSG_TYPE {
+	ZXDH_TBL_TYPE_READ,
+	ZXDH_TBL_TYPE_WRITE,
+	ZXDH_TBL_TYPE_NON,
+};
+
 struct zxdh_msix_para {
 	uint16_t pcie_id;
 	uint16_t vector_risc;
drivers/net/zxdh/zxdh_queue.h +4 -0
index fd73f14e2d..66f37ec612 100644
@@ -102,4 +102,8 @@ struct zxdh_virtqueue {
 	struct zxdh_vq_desc_extra vq_descx[];
 } __rte_packed;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* ZXDH_QUEUE_H */
drivers/net/zxdh/zxdh_rxtx.h +4 -0
index ccac7e7834..31b1c8f0a5 100644
@@ -48,4 +48,8 @@ struct zxdh_virtnet_tx {
 	const struct rte_memzone *mz;                 /* mem zone to populate TX ring. */
 } __rte_packed;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* ZXDH_RXTX_H */
Signature · 1 line
2.27.0
#322 lore raw

PATCH v8 7/9 net/zxdh: add configure zxdh intr implementation

In reply to Junlong Wang

configure zxdh intr include risc,dtb. and release intr.

---
 drivers/net/zxdh/zxdh_ethdev.c | 300 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |   8 +
 drivers/net/zxdh/zxdh_msg.c    | 188 +++++++++++++++++++++
 drivers/net/zxdh/zxdh_msg.h    |  13 ++
 drivers/net/zxdh/zxdh_pci.c    |  62 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  12 ++
 6 files changed, 583 insertions(+)
drivers/net/zxdh/zxdh_ethdev.c +300 -0
index 8d9df218ce..5963aed949 100644
@@ -25,6 +25,301 @@ uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+
+	for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+		ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2 + 1], ZXDH_MSI_NO_VECTOR);
+	}
+}
+
+
+static int32_t zxdh_intr_unmask(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (rte_intr_ack(dev->intr_handle) < 0)
+		return -1;
+
+	hw->use_msix = zxdh_vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));
+
+	return 0;
+}
+
+static void zxdh_devconf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+
+	if (zxdh_intr_unmask(dev) < 0)
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+}
+
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_fromriscv_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] + ZXDH_CTRLCH_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_risc2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_riscvf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_RISC, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+/* Interrupt handler triggered by NIC for handling specific interrupt. */
+static void zxdh_frompfvf_intr_handler(void *param)
+{
+	struct rte_eth_dev *dev = param;
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint64_t virt_addr = (uint64_t)(hw->bar_addr[ZXDH_BAR0_INDEX] +
+				ZXDH_MSG_CHAN_PFVFSHARE_OFFSET);
+
+	if (hw->is_pf) {
+		PMD_INIT_LOG(DEBUG, "zxdh_vf2pf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_VF, ZXDH_MSG_CHAN_END_PF, virt_addr, dev);
+	} else {
+		PMD_INIT_LOG(DEBUG, "zxdh_pf2vf_intr_handler");
+		zxdh_bar_irq_recv(ZXDH_MSG_CHAN_END_PF, ZXDH_MSG_CHAN_END_VF, virt_addr, dev);
+	}
+}
+
+static void zxdh_intr_cb_reg(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_register(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_register(tmp, zxdh_frompfvf_intr_handler, dev);
+
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_register(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static void zxdh_intr_cb_unreg(struct rte_eth_dev *dev)
+{
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	/* register callback to update dev config intr */
+	rte_intr_callback_unregister(dev->intr_handle, zxdh_devconf_intr_handler, dev);
+	/* Register rsic_v to pf interrupt callback */
+	struct rte_intr_handle *tmp = hw->risc_intr +
+			(ZXDH_MSIX_FROM_PFVF - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+
+	rte_intr_callback_unregister(tmp, zxdh_frompfvf_intr_handler, dev);
+	tmp = hw->risc_intr + (ZXDH_MSIX_FROM_RISCV - ZXDH_MSIX_INTR_MSG_VEC_BASE);
+	rte_intr_callback_unregister(tmp, zxdh_fromriscv_intr_handler, dev);
+}
+
+static int32_t zxdh_intr_disable(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled)
+		return 0;
+
+	zxdh_intr_cb_unreg(dev);
+	if (rte_intr_disable(dev->intr_handle) < 0)
+		return -1;
+
+	hw->intr_enabled = 0;
+	return 0;
+}
+
+static int32_t zxdh_intr_enable(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->intr_enabled) {
+		zxdh_intr_cb_reg(dev);
+		ret = rte_intr_enable(dev->intr_handle);
+		if (unlikely(ret))
+			PMD_INIT_LOG(ERR, "Failed to enable %s intr", dev->data->name);
+
+		hw->intr_enabled = 1;
+	}
+	return ret;
+}
+
+static int32_t zxdh_intr_release(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
+		ZXDH_VTPCI_OPS(hw)->set_config_irq(hw, ZXDH_MSI_NO_VECTOR);
+
+	zxdh_queues_unbind_intr(dev);
+	zxdh_intr_disable(dev);
+
+	rte_intr_efd_disable(dev->intr_handle);
+	rte_intr_vec_list_free(dev->intr_handle);
+	rte_free(hw->risc_intr);
+	hw->risc_intr = NULL;
+	rte_free(hw->dtb_intr);
+	hw->dtb_intr = NULL;
+	return 0;
+}
+
+static int32_t zxdh_setup_risc_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	uint8_t i;
+
+	if (!hw->risc_intr) {
+		PMD_INIT_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) {
+			PMD_INIT_LOG(ERR, "Failed to allocate risc_intr");
+			return -ENOMEM;
+		}
+	}
+
+	for (i = 0; i < ZXDH_MSIX_INTR_MSG_VEC_NUM; i++) {
+		if (dev->intr_handle->efds[i] < 0) {
+			PMD_INIT_LOG(ERR, "[%u]risc interrupt fd is invalid", i);
+			rte_free(hw->risc_intr);
+			hw->risc_intr = NULL;
+			return -1;
+		}
+
+		struct rte_intr_handle *intr_handle = hw->risc_intr + i;
+
+		intr_handle->fd = dev->intr_handle->efds[i];
+		intr_handle->type = dev->intr_handle->type;
+	}
+
+	return 0;
+}
+
+static int32_t zxdh_setup_dtb_interrupts(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	if (!hw->dtb_intr) {
+		hw->dtb_intr = rte_zmalloc("dtb_intr", sizeof(struct rte_intr_handle), 0);
+		if (hw->dtb_intr == NULL) {
+			PMD_INIT_LOG(ERR, "Failed to allocate dtb_intr");
+			return -ENOMEM;
+		}
+	}
+
+	if (dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1] < 0) {
+		PMD_INIT_LOG(ERR, "[%d]dtb interrupt fd is invalid", ZXDH_MSIX_INTR_DTB_VEC - 1);
+		rte_free(hw->dtb_intr);
+		hw->dtb_intr = NULL;
+		return -1;
+	}
+	hw->dtb_intr->fd = dev->intr_handle->efds[ZXDH_MSIX_INTR_DTB_VEC - 1];
+	hw->dtb_intr->type = dev->intr_handle->type;
+	return 0;
+}
+
+static int32_t zxdh_queues_bind_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t i;
+	uint16_t vec;
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], ZXDH_MSI_NO_VECTOR);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+					i * 2, ZXDH_MSI_NO_VECTOR, vec);
+		}
+	} else {
+		for (i = 0; i < dev->data->nb_rx_queues; ++i) {
+			vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+					hw->vqs[i * 2], i + ZXDH_QUEUE_INTR_VEC_BASE);
+			PMD_INIT_LOG(DEBUG, "vq%d irq set %d, get %d",
+					i * 2, i + ZXDH_QUEUE_INTR_VEC_BASE, vec);
+		}
+	}
+	/* mask all txq intr */
+	for (i = 0; i < dev->data->nb_tx_queues; ++i) {
+		vec = ZXDH_VTPCI_OPS(hw)->set_queue_irq(hw,
+				hw->vqs[(i * 2) + 1], ZXDH_MSI_NO_VECTOR);
+		PMD_INIT_LOG(DEBUG, "vq%d irq set 0x%x, get 0x%x",
+				(i * 2) + 1, ZXDH_MSI_NO_VECTOR, vec);
+	}
+	return 0;
+}
+
+static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+	int32_t ret = 0;
+
+	if (!rte_intr_cap_multiple(dev->intr_handle)) {
+		PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
+		return -ENOTSUP;
+	}
+	zxdh_intr_release(dev);
+	uint8_t nb_efd = ZXDH_MSIX_INTR_DTB_VEC_NUM + ZXDH_MSIX_INTR_MSG_VEC_NUM;
+
+	if (dev->data->dev_conf.intr_conf.rxq)
+		nb_efd += dev->data->nb_rx_queues;
+
+	if (rte_intr_efd_enable(dev->intr_handle, nb_efd)) {
+		PMD_INIT_LOG(ERR, "Fail to create eventfd");
+		return -1;
+	}
+
+	if (rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM)) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %u rxq vectors",
+					hw->max_queue_pairs + ZXDH_INTR_NONQUE_NUM);
+		return -ENOMEM;
+	}
+	PMD_INIT_LOG(DEBUG, "allocate %u rxq vectors", dev->intr_handle->vec_list_size);
+	if (zxdh_setup_risc_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up rsic_v interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	if (zxdh_setup_dtb_interrupts(dev) != 0) {
+		PMD_INIT_LOG(ERR, "Error setting up dtb interrupts!");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_queues_bind_intr(dev) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
+		ret = -1;
+		goto free_intr_vec;
+	}
+
+	if (zxdh_intr_enable(dev) < 0) {
+		PMD_DRV_LOG(ERR, "interrupt enable failed");
+		ret = -1;
+		goto free_intr_vec;
+	}
+	return 0;
+
+free_intr_vec:
+	zxdh_intr_release(dev);
+	return ret;
+}
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -138,9 +433,14 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	if (ret != 0)
 		goto err_zxdh_init;
 
+	ret = zxdh_configure_intr(eth_dev);
+	if (ret != 0)
+		goto err_zxdh_init;
+
 	return ret;
 
 err_zxdh_init:
+	zxdh_intr_release(eth_dev);
 	zxdh_bar_msg_chan_exit();
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
drivers/net/zxdh/zxdh_ethdev.h +8 -0
index 1ee8dd744c..0a7b574477 100644
@@ -8,6 +8,10 @@
 #include <rte_ether.h>
 
 #include "ethdev_driver.h"
+#include <rte_interrupts.h>
+#include <eal_interrupts.h>
+
+#include "zxdh_queue.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -44,6 +48,9 @@ struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
 	struct zxdh_net_config *dev_cfg;
+	struct rte_intr_handle *risc_intr;
+	struct rte_intr_handle *dtb_intr;
+	struct zxdh_virtqueue **vqs;
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -60,6 +67,7 @@ struct zxdh_hw {
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
+	uint8_t intr_enabled;
 	uint8_t use_msix;
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 
drivers/net/zxdh/zxdh_msg.c +188 -0

203 lines not on this page · raw message

drivers/net/zxdh/zxdh_msg.h +13 -0
index 7da60ee189..691a847462 100644
@@ -15,8 +15,15 @@ extern "C" {
 
 #define ZXDH_BAR0_INDEX     0
 #define ZXDH_CTRLCH_OFFSET  (0x2000)
+#define ZXDH_MSG_CHAN_PFVFSHARE_OFFSET  (ZXDH_CTRLCH_OFFSET + 0x1000)
 
 #define ZXDH_MSIX_INTR_MSG_VEC_BASE  1
+#define ZXDH_MSIX_INTR_MSG_VEC_NUM   3
+#define ZXDH_MSIX_INTR_DTB_VEC      (ZXDH_MSIX_INTR_MSG_VEC_BASE + ZXDH_MSIX_INTR_MSG_VEC_NUM)
+#define ZXDH_MSIX_INTR_DTB_VEC_NUM   1
+#define ZXDH_INTR_NONQUE_NUM        (ZXDH_MSIX_INTR_MSG_VEC_NUM + ZXDH_MSIX_INTR_DTB_VEC_NUM + 1)
+#define ZXDH_QUEUE_INTR_VEC_BASE    (ZXDH_MSIX_INTR_DTB_VEC + ZXDH_MSIX_INTR_DTB_VEC_NUM)
+#define ZXDH_QUEUE_INTR_VEC_NUM      256
 
 #define ZXDH_BAR_MSG_POLLING_SPAN     100
 #define ZXDH_BAR_MSG_POLL_CNT_PER_MS  (1 * 1000 / ZXDH_BAR_MSG_POLLING_SPAN)
@@ -202,6 +209,10 @@ struct zxdh_bar_msg_header {
 	uint16_t dst_pcieid; /* used in PF-->VF */
 };
 
+typedef int (*zxdh_bar_chan_msg_recv_callback)(void *pay_load, uint16_t len,
+					void *reps_buffer, uint16_t *reps_len, void *dev);
+
+
 int zxdh_msg_chan_init(void);
 int zxdh_bar_msg_chan_exit(void);
 int zxdh_msg_chan_hwlock_init(struct rte_eth_dev *dev);
@@ -210,6 +221,8 @@ int zxdh_msg_chan_enable(struct rte_eth_dev *dev);
 int zxdh_bar_chan_sync_msg_send(struct zxdh_pci_bar_msg *in,
 			struct zxdh_msg_recviver_mem *result);
 
+int zxdh_bar_irq_recv(uint8_t src, uint8_t dst, uint64_t virt_addr, void *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_pci.c +62 -0

79 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +12 -0
index bb5ae64ddf..55d8c5449c 100644
@@ -22,6 +22,13 @@ enum zxdh_msix_status {
 	ZXDH_MSIX_ENABLED  = 2
 };
 
+/* The bit of the ISR which indicates a device has an interrupt. */
+#define ZXDH_PCI_ISR_INTR    0x1
+/* The bit of the ISR which indicates a device configuration change. */
+#define ZXDH_PCI_ISR_CONFIG  0x2
+/* Vector value used to disable MSI for queue. */
+#define ZXDH_MSI_NO_VECTOR   0x7F
+
 #define ZXDH_PCI_CAPABILITY_LIST          0x34
 #define ZXDH_PCI_CAP_ID_VNDR              0x09
 #define ZXDH_PCI_CAP_ID_MSIX              0x11
@@ -124,6 +131,9 @@ struct zxdh_pci_ops {
 
 	uint64_t (*get_features)(struct zxdh_hw *hw);
 	void     (*set_features)(struct zxdh_hw *hw, uint64_t features);
+	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
+	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
+	uint8_t  (*get_isr)(struct zxdh_hw *hw);
 };
 
 struct zxdh_hw_internal {
@@ -143,6 +153,8 @@ int32_t zxdh_read_pci_caps(struct rte_pci_device *dev, struct zxdh_hw *hw);
 int32_t zxdh_get_pci_dev_config(struct zxdh_hw *hw);
 
 uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
+uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
+enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
 
 #ifdef __cplusplus
 }
Signature · 1 line
2.27.0
#323 lore raw

PATCH v8 8/9 net/zxdh: add zxdh dev infos get ops

In reply to Junlong Wang

Add support for zxdh infos get.

---
 drivers/net/zxdh/zxdh_ethdev.c | 44 +++++++++++++++++++++++++++++++++-
 drivers/net/zxdh/zxdh_ethdev.h |  3 +++
 2 files changed, 46 insertions(+), 1 deletion(-)
drivers/net/zxdh/zxdh_ethdev.c +43 -1
index 5963aed949..bf0d9b7b3a 100644
@@ -25,6 +25,43 @@ uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v)
 		return (v.epid * 8 + v.pfid) + 1152;
 }
 
+static int32_t zxdh_dev_infos_get(struct rte_eth_dev *dev,
+					struct rte_eth_dev_info *dev_info)
+{
+	struct zxdh_hw *hw = dev->data->dev_private;
+
+	dev_info->speed_capa       = rte_eth_speed_bitflag(hw->speed, RTE_ETH_LINK_FULL_DUPLEX);
+	dev_info->max_rx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_RX_QUEUES_MAX);
+	dev_info->max_tx_queues    = RTE_MIN(hw->max_queue_pairs, ZXDH_TX_QUEUES_MAX);
+	dev_info->min_rx_bufsize   = ZXDH_MIN_RX_BUFSIZE;
+	dev_info->max_rx_pktlen    = ZXDH_MAX_RX_PKTLEN;
+	dev_info->max_mac_addrs    = ZXDH_MAX_MAC_ADDRS;
+	dev_info->rx_offload_capa  = (RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
+					RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
+					RTE_ETH_RX_OFFLOAD_QINQ_STRIP);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM);
+	dev_info->rx_offload_capa |= (RTE_ETH_RX_OFFLOAD_SCATTER);
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_TCP_LRO;
+	dev_info->rx_offload_capa |=  RTE_ETH_RX_OFFLOAD_RSS_HASH;
+
+	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);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
+					RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+					RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO);
+	dev_info->tx_offload_capa |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+					RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM);
+
+	return 0;
+}
+
 static void zxdh_queues_unbind_intr(struct rte_eth_dev *dev)
 {
 	struct zxdh_hw *hw = dev->data->dev_private;
@@ -320,6 +357,11 @@ static int32_t zxdh_configure_intr(struct rte_eth_dev *dev)
 	return ret;
 }
 
+/* dev_ops for zxdh, bare necessities for basic operation */
+static const struct eth_dev_ops zxdh_eth_dev_ops = {
+	.dev_infos_get			 = zxdh_dev_infos_get,
+};
+
 static int32_t zxdh_init_device(struct rte_eth_dev *eth_dev)
 {
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
@@ -376,7 +418,7 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	struct zxdh_hw *hw = eth_dev->data->dev_private;
 	int ret = 0;
 
-	eth_dev->dev_ops = NULL;
+	eth_dev->dev_ops = &zxdh_eth_dev_ops;
 
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
drivers/net/zxdh/zxdh_ethdev.h +3 -0
index 0a7b574477..78f5ca6c00 100644
@@ -33,6 +33,9 @@ extern "C" {
 #define ZXDH_RX_QUEUES_MAX     128U
 #define ZXDH_TX_QUEUES_MAX     128U
 
+#define ZXDH_MIN_RX_BUFSIZE    64
+#define ZXDH_MAX_RX_PKTLEN     14000U
+
 union zxdh_virport_num {
 	uint16_t vport;
 	struct {
Signature · 1 line
2.27.0
#324 lore raw

PATCH v8 9/9 net/zxdh: add zxdh dev configure ops

In reply to Junlong Wang

provided zxdh dev configure ops for queue
check,reset,alloc resources,etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_common.c | 135 ++++++++++
 drivers/net/zxdh/zxdh_common.h |  12 +
 drivers/net/zxdh/zxdh_ethdev.c | 450 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_ethdev.h |  34 ++-
 drivers/net/zxdh/zxdh_pci.c    |  98 +++++++
 drivers/net/zxdh/zxdh_pci.h    |  37 ++-
 drivers/net/zxdh/zxdh_queue.c  | 123 +++++++++
 drivers/net/zxdh/zxdh_queue.h  | 173 +++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |   4 +-
 10 files changed, 1051 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_queue.c
drivers/net/zxdh/meson.build +1 -0
index a16db47f89..b96aa5a27e 100644
@@ -18,4 +18,5 @@ sources = files(
         'zxdh_pci.c',
         'zxdh_msg.c',
         'zxdh_common.c',
+        'zxdh_queue.c',
 )
drivers/net/zxdh/zxdh_common.c +135 -0

144 lines not on this page · raw message

drivers/net/zxdh/zxdh_common.h +12 -0
index f098ae4cf9..a60e25b2e3 100644
@@ -14,6 +14,10 @@
 extern "C" {
 #endif
 
+#define ZXDH_VF_LOCK_REG               0x90
+#define ZXDH_VF_LOCK_ENABLE_MASK       0x1
+#define ZXDH_ACQUIRE_CHANNEL_NUM_MAX   10
+
 struct zxdh_res_para {
 	uint64_t virt_addr;
 	uint16_t pcie_id;
@@ -23,6 +27,14 @@ struct zxdh_res_para {
 int32_t zxdh_phyport_get(struct rte_eth_dev *dev, uint8_t *phyport);
 int32_t zxdh_pannelid_get(struct rte_eth_dev *dev, uint8_t *pannelid);
 
+uint32_t zxdh_read_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg);
+void zxdh_write_bar_reg(struct rte_eth_dev *dev, uint32_t bar, uint32_t reg, uint32_t val);
+void zxdh_release_lock(struct zxdh_hw *hw);
+int32_t zxdh_timedlock(struct zxdh_hw *hw, uint32_t us);
+uint32_t zxdh_read_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg);
+void zxdh_write_comm_reg(uint64_t pci_comm_cfg_baseaddr, uint32_t reg, uint32_t val);
+int32_t zxdh_datach_set(struct rte_eth_dev *dev);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_ethdev.c +450 -0

464 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +24 -10
index 78f5ca6c00..49ddb505d8 100644
@@ -11,8 +11,6 @@
 #include <rte_interrupts.h>
 #include <eal_interrupts.h>
 
-#include "zxdh_queue.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -25,16 +23,23 @@ extern "C" {
 #define ZXDH_E312_PF_DEVICEID     0x8049
 #define ZXDH_E312_VF_DEVICEID     0x8060
 
-#define ZXDH_MAX_UC_MAC_ADDRS  32
-#define ZXDH_MAX_MC_MAC_ADDRS  32
-#define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
+#define ZXDH_MAX_UC_MAC_ADDRS     32
+#define ZXDH_MAX_MC_MAC_ADDRS     32
+#define ZXDH_MAX_MAC_ADDRS       (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
+
+#define ZXDH_NUM_BARS             2
+#define ZXDH_RX_QUEUES_MAX        128U
+#define ZXDH_TX_QUEUES_MAX        128U
 
-#define ZXDH_NUM_BARS          2
-#define ZXDH_RX_QUEUES_MAX     128U
-#define ZXDH_TX_QUEUES_MAX     128U
+#define ZXDH_MIN_RX_BUFSIZE       64
+#define ZXDH_MAX_RX_PKTLEN        14000U
+#define ZXDH_QUEUE_DEPTH          1024
+#define ZXDH_QUEUES_BASE          0
+#define ZXDH_TOTAL_QUEUES_NUM     4096
+#define ZXDH_QUEUES_NUM_MAX       256
+#define ZXDH_QUERES_SHARE_BASE    (0x5000)
 
-#define ZXDH_MIN_RX_BUFSIZE    64
-#define ZXDH_MAX_RX_PKTLEN     14000U
+#define ZXDH_MBUF_BURST_SZ        64
 
 union zxdh_virport_num {
 	uint16_t vport;
@@ -47,6 +52,11 @@ union zxdh_virport_num {
 	};
 };
 
+struct zxdh_chnl_context {
+	uint16_t valid;
+	uint16_t ph_chno;
+};
+
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
 	struct zxdh_pci_common_cfg *common_cfg;
@@ -54,6 +64,7 @@ struct zxdh_hw {
 	struct rte_intr_handle *risc_intr;
 	struct rte_intr_handle *dtb_intr;
 	struct zxdh_virtqueue **vqs;
+	struct zxdh_chnl_context channel_context[ZXDH_QUEUES_NUM_MAX];
 	union zxdh_virport_num vport;
 
 	uint64_t bar_addr[ZXDH_NUM_BARS];
@@ -67,6 +78,7 @@ struct zxdh_hw {
 	uint16_t device_id;
 	uint16_t port_id;
 	uint16_t vfid;
+	uint16_t queue_num;
 
 	uint8_t *isr;
 	uint8_t weak_barriers;
@@ -79,6 +91,8 @@ struct zxdh_hw {
 	uint8_t msg_chan_init;
 	uint8_t phyport;
 	uint8_t panel_id;
+	uint8_t has_tx_offload;
+	uint8_t has_rx_offload;
 };
 
 uint16_t zxdh_vport_to_vfid(union zxdh_virport_num v);
drivers/net/zxdh/zxdh_pci.c +98 -0

116 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h +33 -4
index 55d8c5449c..231824f3c4 100644
@@ -8,7 +8,9 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <bus_pci_driver.h>
+#include <ethdev_driver.h>
 
 #include "zxdh_ethdev.h"
 
@@ -29,13 +31,25 @@ enum zxdh_msix_status {
 /* Vector value used to disable MSI for queue. */
 #define ZXDH_MSI_NO_VECTOR   0x7F
 
-#define ZXDH_PCI_CAPABILITY_LIST          0x34
-#define ZXDH_PCI_CAP_ID_VNDR              0x09
-#define ZXDH_PCI_CAP_ID_MSIX              0x11
+#define ZXDH_PCI_CAPABILITY_LIST     0x34
+#define ZXDH_PCI_CAP_ID_VNDR         0x09
+#define ZXDH_PCI_CAP_ID_MSIX         0x11
 
-#define ZXDH_PCI_MSIX_ENABLE              0x8000
+#define ZXDH_PCI_MSIX_ENABLE         0x8000
+#define ZXDH_PCI_VRING_ALIGN         4096
 
+#define ZXDH_NET_F_CSUM              0   /* Host handles pkts w/ partial csum */
+#define ZXDH_NET_F_GUEST_CSUM        1   /* Guest handles pkts w/ partial csum */
+#define ZXDH_NET_F_MTU               3   /* Initial MTU advice. */
 #define ZXDH_NET_F_MAC               5   /* Host has given MAC address. */
+#define ZXDH_NET_F_GUEST_TSO4        7   /* Guest can handle TSOv4 in. */
+#define ZXDH_NET_F_GUEST_TSO6        8   /* Guest can handle TSOv6 in. */
+#define ZXDH_NET_F_GUEST_ECN         9   /* Guest can handle TSO[6] w/ ECN in. */
+#define ZXDH_NET_F_GUEST_UFO         10  /* Guest can handle UFO in. */
+
+#define ZXDH_NET_F_HOST_UFO          14  /* Host can handle UFO in. */
+#define ZXDH_NET_F_HOST_TSO4         11  /* Host can handle TSOv4 in. */
+#define ZXDH_NET_F_HOST_TSO6         12  /* Host can handle TSOv6 in. */
 #define ZXDH_NET_F_MRG_RXBUF         15  /* Host can merge receive buffers. */
 #define ZXDH_NET_F_STATUS            16  /* zxdh_net_config.status available */
 #define ZXDH_NET_F_MQ                22  /* Device supports Receive Flow Steering */
@@ -60,6 +74,8 @@ enum zxdh_msix_status {
 #define ZXDH_CONFIG_STATUS_DEV_NEED_RESET  0x40
 #define ZXDH_CONFIG_STATUS_FAILED          0x80
 
+#define ZXDH_PCI_QUEUE_ADDR_SHIFT          12
+
 struct zxdh_net_config {
 	/* The config defining mac address (if ZXDH_NET_F_MAC) */
 	uint8_t    mac[RTE_ETHER_ADDR_LEN];
@@ -122,6 +138,11 @@ static inline int32_t vtpci_with_feature(struct zxdh_hw *hw, uint64_t bit)
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int32_t vtpci_packed_queue(struct zxdh_hw *hw)
+{
+	return vtpci_with_feature(hw, ZXDH_F_RING_PACKED);
+}
+
 struct zxdh_pci_ops {
 	void     (*read_dev_cfg)(struct zxdh_hw *hw, size_t offset, void *dst, int32_t len);
 	void     (*write_dev_cfg)(struct zxdh_hw *hw, size_t offset, const void *src, int32_t len);
@@ -134,6 +155,11 @@ struct zxdh_pci_ops {
 	uint16_t (*set_queue_irq)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq, uint16_t vec);
 	uint16_t (*set_config_irq)(struct zxdh_hw *hw, uint16_t vec);
 	uint8_t  (*get_isr)(struct zxdh_hw *hw);
+	uint16_t (*get_queue_num)(struct zxdh_hw *hw, uint16_t queue_id);
+	void     (*set_queue_num)(struct zxdh_hw *hw, uint16_t queue_id, uint16_t vq_size);
+
+	int32_t  (*setup_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
+	void     (*del_queue)(struct zxdh_hw *hw, struct zxdh_virtqueue *vq);
 };
 
 struct zxdh_hw_internal {
@@ -156,6 +182,9 @@ uint16_t zxdh_vtpci_get_features(struct zxdh_hw *hw);
 uint8_t zxdh_vtpci_isr(struct zxdh_hw *hw);
 enum zxdh_msix_status zxdh_vtpci_msix_detect(struct rte_pci_device *dev);
 
+void zxdh_vtpci_reinit_complete(struct zxdh_hw *hw);
+void zxdh_vtpci_set_status(struct zxdh_hw *hw, uint8_t status);
+
 #ifdef __cplusplus
 }
 #endif
drivers/net/zxdh/zxdh_queue.c new file +123 -0

123 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h +173 -0

196 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h +2 -2
index 31b1c8f0a5..7d4b5481ec 100644
@@ -40,8 +40,8 @@ struct zxdh_virtnet_rx {
 
 struct zxdh_virtnet_tx {
 	struct zxdh_virtqueue         *vq;
-	const struct rte_memzone *virtio_net_hdr_mz;  /* memzone to populate hdr. */
-	rte_iova_t                virtio_net_hdr_mem; /* hdr for each xmit packet */
+	const struct rte_memzone *zxdh_net_hdr_mz;  /* memzone to populate hdr. */
+	rte_iova_t                zxdh_net_hdr_mem; /* hdr for each xmit packet */
 	uint16_t                  queue_id;           /* DPDK queue index. */
 	uint16_t                  port_id;            /* Device port identifier. */
 	struct zxdh_virtnet_stats      stats;
Signature · 1 line
2.27.0
#325 lore raw

PATCH v7 2/9 net/zxdh: add logging implementation

In reply to Junlong Wang

Add zxdh logging implementation.

---
 drivers/net/zxdh/zxdh_ethdev.c | 15 +++++++++++--
 drivers/net/zxdh/zxdh_logs.h   | 40 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_logs.h
drivers/net/zxdh/zxdh_ethdev.c +13 -2
index 75d8b28cc3..7220770c01 100644
@@ -7,6 +7,7 @@
 #include <rte_ethdev.h>
 
 #include "zxdh_ethdev.h"
+#include "zxdh_logs.h"
 
 static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -19,13 +20,18 @@ static int zxdh_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Allocate memory for storing MAC addresses */
 	eth_dev->data->mac_addrs = rte_zmalloc("zxdh_mac",
 			ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
-	if (eth_dev->data->mac_addrs == NULL)
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes store MAC addresses",
+				ZXDH_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN);
 		return -ENOMEM;
+	}
 
 	memset(hw, 0, sizeof(*hw));
 	hw->bar_addr[0] = (uint64_t)pci_dev->mem_resource[0].addr;
-	if (hw->bar_addr[0] == 0)
+	if (hw->bar_addr[0] == 0) {
+		PMD_INIT_LOG(ERR, "Bad mem resource.");
 		return -EIO;
+	}
 
 	hw->device_id = pci_dev->id.device_id;
 	hw->port_id = eth_dev->data->port_id;
@@ -90,3 +96,8 @@ static struct rte_pci_driver zxdh_pmd = {
 RTE_PMD_REGISTER_PCI(net_zxdh, zxdh_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_zxdh, pci_id_zxdh_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_zxdh, "* vfio-pci");
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_init, init, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_driver, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_rx, rx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_tx, tx, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(zxdh_logtype_msg, msg, NOTICE);
drivers/net/zxdh/zxdh_logs.h new file +40 -0
new file mode 100644
index 0000000000..a8a6a3135b
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 ZTE Corporation
+ */
+
+#ifndef ZXDH_LOGS_H
+#define ZXDH_LOGS_H
+
+#include <rte_log.h>
+
+extern int zxdh_logtype_init;
+#define RTE_LOGTYPE_ZXDH_INIT zxdh_logtype_init
+#define PMD_INIT_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_INIT, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_driver;
+#define RTE_LOGTYPE_ZXDH_DRIVER zxdh_logtype_driver
+#define PMD_DRV_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_DRIVER, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_rx;
+#define RTE_LOGTYPE_ZXDH_RX zxdh_logtype_rx
+#define PMD_RX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_RX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_tx;
+#define RTE_LOGTYPE_ZXDH_TX zxdh_logtype_tx
+#define PMD_TX_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_TX, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+extern int zxdh_logtype_msg;
+#define RTE_LOGTYPE_ZXDH_MSG zxdh_logtype_msg
+#define PMD_MSG_LOG(level, ...) \
+	RTE_LOG_LINE_PREFIX(level, ZXDH_MSG, "offload_zxdh %s(): ", \
+		__func__, __VA_ARGS__)
+
+#endif /* ZXDH_LOGS_H */
Signature · 1 line
2.27.0
#326 lore raw

PATCH v7 3/9 net/zxdh: add zxdh device pci init implementation

In reply to Junlong Wang

Add device pci init implementation,
to obtain PCI capability and read configuration, etc.

---
 drivers/net/zxdh/meson.build   |   1 +
 drivers/net/zxdh/zxdh_ethdev.c |  43 +++++
 drivers/net/zxdh/zxdh_ethdev.h |  22 ++-
 drivers/net/zxdh/zxdh_pci.c    | 290 +++++++++++++++++++++++++++++++++
 drivers/net/zxdh/zxdh_pci.h    | 151 +++++++++++++++++
 drivers/net/zxdh/zxdh_queue.h  | 105 ++++++++++++
 drivers/net/zxdh/zxdh_rxtx.h   |  51 ++++++
 7 files changed, 660 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/zxdh/zxdh_pci.c
 create mode 100644 drivers/net/zxdh/zxdh_pci.h
 create mode 100644 drivers/net/zxdh/zxdh_queue.h
 create mode 100644 drivers/net/zxdh/zxdh_rxtx.h
drivers/net/zxdh/meson.build +1 -0
index 932fb1c835..7db4e7bc71 100644
@@ -15,4 +15,5 @@ endif
 
 sources = files(
         'zxdh_ethdev.c',
+        'zxdh_pci.c',
 )
drivers/net/zxdh/zxdh_ethdev.c +43 -0

55 lines not on this page · raw message

drivers/net/zxdh/zxdh_ethdev.h +19 -3
index 086f3a0cdc..e2db2508e2 100644
@@ -5,6 +5,8 @@
 #ifndef ZXDH_ETHDEV_H
 #define ZXDH_ETHDEV_H
 
+#include <rte_ether.h>
+
 #include "ethdev_driver.h"
 
 #ifdef __cplusplus
@@ -23,16 +25,30 @@ extern "C" {
 #define ZXDH_MAX_MC_MAC_ADDRS     32
 #define ZXDH_MAX_MAC_ADDRS     (ZXDH_MAX_UC_MAC_ADDRS + ZXDH_MAX_MC_MAC_ADDRS)
 
-#define ZXDH_NUM_BARS    2
+#define ZXDH_NUM_BARS       2
+#define ZXDH_RX_QUEUES_MAX  128U
+#define ZXDH_TX_QUEUES_MAX  128U
 
 struct zxdh_hw {
 	struct rte_eth_dev *eth_dev;
-	uint64_t bar_addr[ZXDH_NUM_BARS];
+	struct zxdh_pci_common_cfg *common_cfg;
+	struct zxdh_net_config *dev_cfg;
 
-	uint32_t  speed;
+	uint64_t bar_addr[ZXDH_NUM_BARS];
+	uint64_t host_features;
+	uint64_t guest_features;
+	uint32_t max_queue_pairs;
+	uint32_t speed;
+	uint32_t notify_off_multiplier;
+	uint16_t *notify_base;
+	uint16_t pcie_id;
 	uint16_t device_id;
 	uint16_t port_id;
 
+	uint8_t *isr;
+	uint8_t weak_barriers;
+	uint8_t use_msix;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t duplex;
 	uint8_t is_pf;
 };
drivers/net/zxdh/zxdh_pci.c new file +290 -0

290 lines not on this page · raw message

drivers/net/zxdh/zxdh_pci.h new file +151 -0

151 lines not on this page · raw message

drivers/net/zxdh/zxdh_queue.h new file +105 -0

105 lines not on this page · raw message

drivers/net/zxdh/zxdh_rxtx.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.27.0