diff mbox series

[v7,4/7] bus/dpaa: add Virtual Storage Profile port init

Message ID 20200904082921.17400-4-hemant.agrawal@nxp.com
State Superseded
Headers show
Series [v7,1/7] net/dpaa: add VSP support in FMLIB | expand

Commit Message

Hemant Agrawal Sept. 4, 2020, 8:29 a.m. UTC
This patch add support to initialize the VSP ports
in the FMAN library.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 drivers/bus/dpaa/base/fman/fman.c | 57 +++++++++++++++++++++++++++++++
 drivers/bus/dpaa/include/fman.h   |  3 ++
 2 files changed, 60 insertions(+)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c
index 3ae29bf06..39102bc1f 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -145,6 +145,61 @@  fman_get_mac_index(uint64_t regs_addr_host, uint8_t *mac_idx)
 	return ret;
 }
 
+static void fman_if_vsp_init(struct __fman_if *__if)
+{
+	const phandle *prop;
+	int cell_index;
+	const struct device_node *dev;
+	size_t lenp;
+	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+
+	if (__if->__if.mac_type == fman_mac_1g) {
+		for_each_compatible_node(dev, NULL,
+			"fsl,fman-port-1g-rx-extended-args") {
+			prop = of_get_property(dev, "cell-index", &lenp);
+			if (prop) {
+				cell_index = of_read_number(
+						&prop[0],
+						lenp / sizeof(phandle));
+				if (cell_index == mac_idx[__if->__if.mac_idx]) {
+					prop = of_get_property(
+							dev,
+							"vsp-window", &lenp);
+					if (prop) {
+						__if->__if.num_profiles =
+							of_read_number(
+								&prop[0], 1);
+						__if->__if.base_profile_id =
+							of_read_number(
+								&prop[1], 1);
+					}
+				}
+			}
+		}
+	} else if (__if->__if.mac_type == fman_mac_10g) {
+		for_each_compatible_node(dev, NULL,
+			"fsl,fman-port-10g-rx-extended-args") {
+			prop = of_get_property(dev, "cell-index", &lenp);
+			if (prop) {
+				cell_index = of_read_number(
+					&prop[0], lenp / sizeof(phandle));
+				if (cell_index == mac_idx[__if->__if.mac_idx]) {
+					prop = of_get_property(
+						dev, "vsp-window", &lenp);
+					if (prop) {
+						__if->__if.num_profiles =
+							of_read_number(
+								&prop[0], 1);
+						__if->__if.base_profile_id =
+							of_read_number(
+								&prop[1], 1);
+					}
+				}
+			}
+		}
+	}
+}
+
 static int
 fman_if_init(const struct device_node *dpa_node)
 {
@@ -519,6 +574,8 @@  fman_if_init(const struct device_node *dpa_node)
 	if (is_shared)
 		__if->__if.is_shared_mac = 1;
 
+	fman_if_vsp_init(__if);
+
 	/* Parsing of the network interface is complete, add it to the list */
 	DPAA_BUS_LOG(DEBUG, "Found %s, Tx Channel = %x, FMAN = %x,"
 		    "Port ID = %x",
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index cb7f18ca2..dcf408372 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -321,6 +321,9 @@  struct fman_if {
 	/* The Qman channel to schedule Tx FQs to */
 	u16 tx_channel_id;
 
+	uint8_t base_profile_id;
+	uint8_t num_profiles;
+
 	uint8_t is_shared_mac;
 	/* The hard-coded FQIDs for this interface. Note: this doesn't cover
 	 * the PCD nor the "Rx default" FQIDs, which are configured via FMC