Skip to contentSkip to conversation

net/xsc: add representor ports probe

PATCH Superseded WanRenyong 1 participant 1 message Sep 6, 2024 Network drivers

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

WanRenyong

author
#0 lore raw

PATCH 7/19 net/xsc: add representor ports probe

XSC representor port is designed to store representor resources. In addition to common representor ports, xsc device is a special representor port.

---
 drivers/net/xsc/xsc_defs.h  |  24 +++++++
 drivers/net/xsc/xsc_dev.c   | 103 +++++++++++++++++++++++++++++-
 drivers/net/xsc/xsc_dev.h   |  27 ++++++++
 drivers/net/xsc/xsc_utils.c | 122 ++++++++++++++++++++++++++++++++++++
 drivers/net/xsc/xsc_utils.h |   3 +
 5 files changed, 278 insertions(+), 1 deletion(-)
drivers/net/xsc/xsc_defs.h +24 -0
index 97cd61b2d1..8cb67ed2e1 100644
@@ -8,6 +8,10 @@
 #define XSC_PCI_VENDOR_ID		0x1f67
 #define XSC_PCI_DEV_ID_MS		0x1111
 
+#define XSC_VFREP_BASE_LOGICAL_PORT 1081
+
+
+
 enum xsc_nic_mode {
 	XSC_NIC_MODE_LEGACY,
 	XSC_NIC_MODE_SWITCHDEV,
@@ -31,5 +35,25 @@ enum xsc_flow_mode {
 	XSC_FLOW_MODE_MAX,
 };
 
+enum xsc_funcid_type {
+	XSC_FUNCID_TYPE_INVAL	= 0x0,
+	XSC_EMU_FUNCID		= 0x1,
+	XSC_PHYPORT_MAC_FUNCID	= 0x2,
+	XSC_VF_IOCTL_FUNCID	= 0x3,
+	XSC_PHYPORT_LAG_FUNCID	= 0x4,
+	XSC_FUNCID_TYPE_UNKNOWN	= 0x5,
+};
+
+enum xsc_phy_port_type {
+	XSC_PORT_TYPE_NONE = 0,
+	XSC_PORT_TYPE_UPLINK, /* mac0rep */
+	XSC_PORT_TYPE_UPLINK_BOND, /* bondrep */
+	XSC_PORT_TYPE_PFVF, /*hasreps: vfrep*/
+	XSC_PORT_TYPE_PFHPF, /*hasreps: host pf rep*/
+	XSC_PORT_TYPE_UNKNOWN,
+};
+
+#define XSC_PHY_PORT_NUM 1
+
 #endif /* XSC_DEFS_H_ */
 
drivers/net/xsc/xsc_dev.c +102 -1

128 lines not on this page · raw message

drivers/net/xsc/xsc_dev.h +27 -0
index 5f0e911b42..93ab1e24fe 100644
@@ -7,10 +7,14 @@
 
 #include <infiniband/verbs.h>
 
+#include "xsc_defs.h"
+
 #define XSC_PPH_MODE_ARG "pph_mode"
 #define XSC_NIC_MODE_ARG "nic_mode"
 #define XSC_FLOW_MODE_ARG "flow_mode"
 
+#define XSC_DEV_REPR_PORT	0
+
 struct xsc_hwinfo {
 	uint8_t valid; /* 1: current phy info is valid, 0 : invalid */
 	uint32_t pcie_no; /* pcie number , 0 or 1 */
@@ -48,10 +52,32 @@ struct xsc_devargs {
 	int pph_mode;
 };
 
+struct xsc_repr_info {
+	int32_t repr_id;
+	enum xsc_phy_port_type port_type;
+	int pf_bond;
+
+	uint32_t ifindex;
+	const char *phys_dev_name;
+	uint32_t funcid;
+};
+
+struct xsc_repr_port {
+	struct xsc_dev *xdev;
+	struct xsc_repr_info info;
+	void *drv_data;
+};
+
 struct xsc_dev {
 	struct rte_pci_device *pci_dev;
 	struct xsc_devargs devargs;
 	struct xsc_hwinfo hwinfo;
+	int vfos_logical_in_port;
+
+	struct xsc_repr_port *repr_ports;
+	int num_repr_ports;
+	int ifindex;
+
 	struct ibv_context *ibv_ctx;
 	struct ibv_pd *ibv_pd;
 	char ibv_name[IBV_SYSFS_NAME_MAX];
@@ -62,5 +88,6 @@ struct xsc_dev {
 
 int xsc_dev_init(struct rte_pci_device *pci_dev, struct xsc_dev **dev);
 void xsc_dev_uninit(struct xsc_dev *dev);
+int xsc_repr_ports_probe(struct xsc_dev *dev, int nb_port, int max_nb_ports);
 
 #endif /* _XSC_DEV_H_ */
drivers/net/xsc/xsc_utils.c +122 -0

131 lines not on this page · raw message

drivers/net/xsc/xsc_utils.h +3 -0
index 0bc318e96a..0d4596489a 100644
@@ -10,5 +10,8 @@
 #include <ethdev_pci.h>
 
 struct ibv_device *xsc_get_ibv_device(const struct rte_pci_addr *addr);
+int xsc_get_ifname_by_pci_addr(struct rte_pci_addr *addr, char *ifname);
+int xsc_get_ifindex_by_ifname(const char *ifname, int *ifindex);
+int xsc_get_ifindex_by_pci_addr(struct rte_pci_addr *addr, int *ifindex);
 
 #endif /* _XSC_UTILS_H_ */
Signature · 1 line
2.25.1