Skip to contentSkip to conversation

mips: octeon: Add ethernet support

PATCH Superseded Stefan Roese 2 participants 52 messages Mar 30, 2022 – Mar 31, 2022 Page 3 of 3

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#32 lore raw

PATCH 36/52 mips: octeon: Add cvmx-pko3-queue.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-pko3-queue.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 arch/mips/mach-octeon/cvmx-pko3-queue.c | 1331 +++++++++++++++++++++++
 1 file changed, 1331 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c
arch/mips/mach-octeon/cvmx-pko3-queue.c new file +1331 -0
new file mode 100644
index 000000000000..d1b48d4cb8de
@@ -0,0 +1,1331 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ */
+
+#include <errno.h>
+#include <log.h>
+#include <time.h>
+#include <linux/delay.h>
+
+#include <mach/cvmx-regs.h>
+#include <mach/cvmx-csr.h>
+#include <mach/cvmx-bootmem.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+#include <mach/cvmx-pcie.h>
+#include <mach/cvmx-coremask.h>
+
+#include <mach/cvmx-agl-defs.h>
+#include <mach/cvmx-bgxx-defs.h>
+#include <mach/cvmx-ciu-defs.h>
+#include <mach/cvmx-gmxx-defs.h>
+#include <mach/cvmx-gserx-defs.h>
+#include <mach/cvmx-ilk-defs.h>
+#include <mach/cvmx-ipd-defs.h>
+#include <mach/cvmx-pcsx-defs.h>
+#include <mach/cvmx-pcsxx-defs.h>
+#include <mach/cvmx-pki-defs.h>
+#include <mach/cvmx-pko-defs.h>
+#include <mach/cvmx-xcv-defs.h>
+
+#include <mach/cvmx-hwpko.h>
+#include <mach/cvmx-ilk.h>
+#include <mach/cvmx-pki.h>
+#include <mach/cvmx-pko3.h>
+#include <mach/cvmx-pko3-queue.h>
+#include <mach/cvmx-pko3-resources.h>
+
+#include <mach/cvmx-helper.h>
+#include <mach/cvmx-helper-board.h>
+#include <mach/cvmx-helper-cfg.h>
+
+#include <mach/cvmx-helper-bgx.h>
+#include <mach/cvmx-helper-cfg.h>
+#include <mach/cvmx-helper-util.h>
+#include <mach/cvmx-helper-pki.h>
+
+/* Smalles Round-Robin quantum to use +1 */
+#define CVMX_PKO3_RR_QUANTUM_MIN 0x10
+
+static int debug; /* 1 for basic, 2 for detailed trace */
+
+struct cvmx_pko3_dq {
+	unsigned dq_count : 6; /* Number of descriptor queues */
+	unsigned dq_base : 10; /* Descriptor queue start number */
+#define CVMX_PKO3_SWIZZLE_IPD 0x0
+};
+
+/*
+ * @INTERNAL
+ * Descriptor Queue to IPD port mapping table.
+ *
+ * This pointer is per-core, contains the virtual address
+ * of a global named block which has 2^12 entries per each
+ * possible node.
+ */
+struct cvmx_pko3_dq *__cvmx_pko3_dq_table;
+
+int cvmx_pko3_get_queue_base(int ipd_port)
+{
+	struct cvmx_pko3_dq *dq_table;
+	int ret = -1;
+	unsigned int i;
+	struct cvmx_xport xp = cvmx_helper_ipd_port_to_xport(ipd_port);
+
+	/* get per-node table */
+	if (cvmx_unlikely(!__cvmx_pko3_dq_table))
+		__cvmx_pko3_dq_table_setup();
+
+	i = CVMX_PKO3_SWIZZLE_IPD ^ xp.port;
+
+	/* get per-node table */
+	dq_table = __cvmx_pko3_dq_table + CVMX_PKO3_IPD_NUM_MAX * xp.node;
+
+	if (cvmx_likely(dq_table[i].dq_count > 0))
+		ret = xp.node << 10 | dq_table[i].dq_base;
+	else if (debug)
+		cvmx_printf("ERROR: %s: no queues for ipd_port=%#x\n", __func__,
+			    ipd_port);
+
+	return ret;
+}
+
+int cvmx_pko3_get_queue_num(int ipd_port)
+{
+	struct cvmx_pko3_dq *dq_table;
+	int ret = -1;
+	unsigned int i;
+	struct cvmx_xport xp = cvmx_helper_ipd_port_to_xport(ipd_port);
+
+	/* get per-node table */
+	if (cvmx_unlikely(!__cvmx_pko3_dq_table))
+		__cvmx_pko3_dq_table_setup();
+
+	i = CVMX_PKO3_SWIZZLE_IPD ^ xp.port;
+
+	/* get per-node table */
+	dq_table = __cvmx_pko3_dq_table + CVMX_PKO3_IPD_NUM_MAX * xp.node;
+
+	if (cvmx_likely(dq_table[i].dq_count > 0))
+		ret = dq_table[i].dq_count;
+	else if (debug)
+		debug("ERROR: %s: no queues for ipd_port=%#x\n", __func__,
+		      ipd_port);
+
+	return ret;
+}
+
+/**
+ * Get L1/Port Queue number assigned to interface port.
+ *
+ * @param xiface is interface number.
+ * @param index is port index.
+ */
+int cvmx_pko3_get_port_queue(int xiface, int index)
+{
+	int queue;
+	cvmx_pko_l1_sqx_topology_t qtop;
+	int mac = __cvmx_pko3_get_mac_num(xiface, index);
+	int nqueues = cvmx_pko3_num_level_queues(CVMX_PKO_PORT_QUEUES);
+	cvmx_xiface_t xi = cvmx_helper_xiface_to_node_interface(xiface);
+
+	for (queue = 0; queue < nqueues; queue++) {
+		qtop.u64 =
+			csr_rd_node(xi.node, CVMX_PKO_L1_SQX_TOPOLOGY(queue));
+		if (qtop.s.link == mac)
+			break;
+	}
+	if (queue >= nqueues)
+		return -1;
+	return queue;
+}
+
+/**
+ * @INTERNAL
+ *
+ * Initialize port/dq table contents
+ */
+static void __cvmx_pko3_dq_table_init(void *ptr)
+{
+	unsigned int size = sizeof(struct cvmx_pko3_dq) *
+			    CVMX_PKO3_IPD_NUM_MAX * CVMX_MAX_NODES;
+
+	memset(ptr, 0, size);
+}
+
+/**
+ * @INTERNAL
+ *
+ * Find or allocate global port/dq map table
+ * which is a named table, contains entries for
+ * all possible OCI nodes.
+ *
+ * The table global pointer is stored in core-local variable
+ * so that every core will call this function once, on first use.
+ */
+int __cvmx_pko3_dq_table_setup(void)
+{
+	void *ptr;
+
+	ptr = cvmx_bootmem_alloc_named_range_once(
+		/* size */
+		sizeof(struct cvmx_pko3_dq) * CVMX_PKO3_IPD_NUM_MAX *
+			CVMX_MAX_NODES,
+		/* min_addr, max_addr, align */
+		0ull, 0ull, sizeof(struct cvmx_pko3_dq),
+		/* name */
+		"cvmx_pko3_global_dq_table", __cvmx_pko3_dq_table_init);
+
+	if (debug)
+		debug("%s: dq_table_ptr=%p\n", __func__, ptr);
+
+	if (!ptr)
+		return -1;
+
+	__cvmx_pko3_dq_table = ptr;
+	return 0;
+}
+
+/*
+ * @INTERNAL
+ * Register a range of Descriptor Queues with an interface port
+ *
+ * This function populates the DQ-to-IPD translation table
+ * used by the application to retrieve the DQ range (typically ordered
+ * by priority) for a given IPD-port, which is either a physical port,
+ * or a channel on a channelized interface (i.e. ILK).
+ *
+ * @param xiface is the physical interface number
+ * @param index is either a physical port on an interface
+ *        or a channel of an ILK interface
+ * @param dq_base is the first Descriptor Queue number in a consecutive range
+ * @param dq_count is the number of consecutive Descriptor Queues leading
+ *        the same channel or port.
+ *
+ * Only a consecutive range of Descriptor Queues can be associated with any
+ * given channel/port, and usually they are ordered from most to least
+ * in terms of scheduling priority.
+ *
+ * Note: thus function only populates the node-local translation table.
+ * NOTE: This function would be cleaner if it had a single ipd_port argument
+ *
+ * @returns 0 on success, -1 on failure.
+ */
+int __cvmx_pko3_ipd_dq_register(int xiface, int index, unsigned int dq_base,
+				unsigned int dq_count)
+{
+	struct cvmx_pko3_dq *dq_table;
+	int ipd_port;
+	unsigned int i;
+	struct cvmx_xiface xi = cvmx_helper_xiface_to_node_interface(xiface);
+	struct cvmx_xport xp;
+
+	if (__cvmx_helper_xiface_is_null(xiface)) {
+		ipd_port = cvmx_helper_node_to_ipd_port(xi.node,
+							CVMX_PKO3_IPD_PORT_NULL);
+	} else {
+		int p;
+
+		p = cvmx_helper_get_ipd_port(xiface, index);
+		if (p < 0) {
+			cvmx_printf("ERROR: %s: xiface %#x has no IPD port\n",
+				    __func__, xiface);
+			return -1;
+		}
+		ipd_port = p;
+	}
+
+	xp = cvmx_helper_ipd_port_to_xport(ipd_port);
+
+	i = CVMX_PKO3_SWIZZLE_IPD ^ xp.port;
+
+	/* get per-node table */
+	if (!__cvmx_pko3_dq_table)
+		__cvmx_pko3_dq_table_setup();
+
+	dq_table = __cvmx_pko3_dq_table + CVMX_PKO3_IPD_NUM_MAX * xi.node;
+
+	if (debug)
+		debug("%s: ipd_port=%#x ix=%#x dq %u cnt %u\n", __func__,
+		      ipd_port, i, dq_base, dq_count);
+
+	/* Check the IPD port has not already been configured */
+	if (dq_table[i].dq_count > 0) {
+		cvmx_printf("%s: ERROR: IPD %#x already registered\n", __func__,
+			    ipd_port);
+		return -1;
+	}
+
+	/* Store DQ# range in the queue lookup table */
+	dq_table[i].dq_base = dq_base;
+	dq_table[i].dq_count = dq_count;
+
+	return 0;
+}
+
+/**
+ * @INTERNAL
+ *
+ * Unregister DQs associated with CHAN_E (IPD port)
+ *
+ * NOTE: This function would be cleaner if it had a single ipd_port argument
+ */
+int __cvmx_pko3_ipd_dq_unregister(int xiface, int index)
+{
+	struct cvmx_pko3_dq *dq_table;
+	int ipd_port;
+	unsigned int i;
+	struct cvmx_xport xp;
+	struct cvmx_xiface xi = cvmx_helper_xiface_to_node_interface(xiface);
+
+	if (__cvmx_helper_xiface_is_null(xiface)) {
+		ipd_port = cvmx_helper_node_to_ipd_port(xi.node,
+							CVMX_PKO3_IPD_PORT_NULL);
+	} else {
+		int p;
+
+		p = cvmx_helper_get_ipd_port(xiface, index);
+		if (p < 0) {
+			cvmx_printf("ERROR: %s: xiface %#x has no IPD port\n",
+				    __func__, xiface);
+			return -1;
+		}
+		ipd_port = p;
+	}
+
+	xp = cvmx_helper_ipd_port_to_xport(ipd_port);
+
+	i = CVMX_PKO3_SWIZZLE_IPD ^ xp.port;
+
+	/* get per-node table */
+	if (!__cvmx_pko3_dq_table)
+		__cvmx_pko3_dq_table_setup();
+
+	/* get per-node table */
+	dq_table = __cvmx_pko3_dq_table + CVMX_PKO3_IPD_NUM_MAX * xi.node;
+
+	if (dq_table[i].dq_count == 0) {
+		cvmx_printf("WARNING: %s:ipd=%#x already released\n", __func__,
+			    ipd_port);
+		return -1;
+	}
+
+	if (debug)
+		debug("%s:ipd_port=%#x release dq %u cnt %u\n", __func__,
+		      ipd_port, dq_table[i].dq_base, dq_table[i].dq_count);
+
+	dq_table[i].dq_count = 0;
+
+	return 0;
+}
+
+/*
+ * @INTERNAL
+ * Convert normal CHAN_E (i.e. IPD port) value to compressed channel form
+ * that is used to populate PKO_LUT.
+ *
+ * Note: This code may be model specific.
+ */
+static int cvmx_pko3_chan_2_xchan(uint16_t ipd_port)
+{
+	u16 xchan;
+	u8 off;
+	static const u8 *xchan_base;
+	static const u8 xchan_base_cn78xx[16] = {
+		/* IPD 0x000 */ 0x3c0 >> 4, /* LBK */
+		/* IPD 0x100 */ 0x380 >> 4, /* DPI */
+		/* IPD 0x200 */ 0xfff >> 4, /* not used */
+		/* IPD 0x300 */ 0xfff >> 4, /* not used */
+		/* IPD 0x400 */ 0x000 >> 4, /* ILK0 */
+		/* IPD 0x500 */ 0x100 >> 4, /* ILK1 */
+		/* IPD 0x600 */ 0xfff >> 4, /* not used */
+		/* IPD 0x700 */ 0xfff >> 4, /* not used */
+		/* IPD 0x800 */ 0x200 >> 4, /* BGX0 */
+		/* IPD 0x900 */ 0x240 >> 4, /* BGX1 */
+		/* IPD 0xa00 */ 0x280 >> 4, /* BGX2 */
+		/* IPD 0xb00 */ 0x2c0 >> 4, /* BGX3 */
+		/* IPD 0xc00 */ 0x300 >> 4, /* BGX4 */
+		/* IPD 0xd00 */ 0x340 >> 4, /* BGX5 */
+		/* IPD 0xe00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xf00 */ 0xfff >> 4  /* not used */
+	};
+	static const u8 xchan_base_cn73xx[16] = {
+		/* IPD 0x000 */ 0x0c0 >> 4, /* LBK */
+		/* IPD 0x100 */ 0x100 >> 4, /* DPI */
+		/* IPD 0x200 */ 0xfff >> 4, /* not used */
+		/* IPD 0x300 */ 0xfff >> 4, /* not used */
+		/* IPD 0x400 */ 0xfff >> 4, /* not used */
+		/* IPD 0x500 */ 0xfff >> 4, /* not used */
+		/* IPD 0x600 */ 0xfff >> 4, /* not used */
+		/* IPD 0x700 */ 0xfff >> 4, /* not used */
+		/* IPD 0x800 */ 0x000 >> 4, /* BGX0 */
+		/* IPD 0x900 */ 0x040 >> 4, /* BGX1 */
+		/* IPD 0xa00 */ 0x080 >> 4, /* BGX2 */
+		/* IPD 0xb00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xc00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xd00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xe00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xf00 */ 0xfff >> 4  /* not used */
+	};
+	static const u8 xchan_base_cn75xx[16] = {
+		/* IPD 0x000 */ 0x040 >> 4, /* LBK */
+		/* IPD 0x100 */ 0x080 >> 4, /* DPI */
+		/* IPD 0x200 */ 0xeee >> 4, /* SRIO0  noop */
+		/* IPD 0x300 */ 0xfff >> 4, /* not used */
+		/* IPD 0x400 */ 0xfff >> 4, /* not used */
+		/* IPD 0x500 */ 0xfff >> 4, /* not used */
+		/* IPD 0x600 */ 0xfff >> 4, /* not used */
+		/* IPD 0x700 */ 0xfff >> 4, /* not used */
+		/* IPD 0x800 */ 0x000 >> 4, /* BGX0 */
+		/* IPD 0x900 */ 0xfff >> 4, /* not used */
+		/* IPD 0xa00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xb00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xc00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xd00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xe00 */ 0xfff >> 4, /* not used */
+		/* IPD 0xf00 */ 0xfff >> 4  /* not used */
+	};
+
+	if (OCTEON_IS_MODEL(OCTEON_CN73XX))
+		xchan_base = xchan_base_cn73xx;
+	if (OCTEON_IS_MODEL(OCTEON_CNF75XX))
+		xchan_base = xchan_base_cn75xx;
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX))
+		xchan_base = xchan_base_cn78xx;
+
+	if (!xchan_base)
+		return -1;
+
+	xchan = ipd_port >> 8;
+
+	/* ILKx, DPI has 8 bits logical channels, others just 6 */
+	if (((xchan & 0xfe) == 0x04) || xchan == 0x01)
+		off = ipd_port & 0xff;
+	else
+		off = ipd_port & 0x3f;
+
+	xchan = xchan_base[xchan & 0xf];
+
+	if (xchan == 0xff)
+		return -1; /* Invalid IPD_PORT */
+	else if (xchan == 0xee)
+		return -2; /* LUT not used */
+	else
+		return (xchan << 4) | off;
+}
+
+/*
+ * Map channel number in PKO
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param pq_num specifies the Port Queue (i.e. L1) queue number.
+ * @param l2_l3_q_num  specifies L2/L3 queue number.
+ * @param channel specifies the channel number to map to the queue.
+ *
+ * The channel assignment applies to L2 or L3 Shaper Queues depending
+ * on the setting of channel credit level.
+ *
+ * @return returns none.
+ */
+void cvmx_pko3_map_channel(unsigned int node, unsigned int pq_num,
+			   unsigned int l2_l3_q_num, uint16_t channel)
+{
+	union cvmx_pko_l3_l2_sqx_channel sqx_channel;
+	cvmx_pko_lutx_t lutx;
+	int xchan;
+
+	sqx_channel.u64 =
+		csr_rd_node(node, CVMX_PKO_L3_L2_SQX_CHANNEL(l2_l3_q_num));
+
+	sqx_channel.s.cc_channel = channel;
+
+	csr_wr_node(node, CVMX_PKO_L3_L2_SQX_CHANNEL(l2_l3_q_num),
+		    sqx_channel.u64);
+
+	/* Convert CHAN_E into compressed channel */
+	xchan = cvmx_pko3_chan_2_xchan(channel);
+
+	if (debug)
+		debug("%s: ipd_port=%#x xchan=%#x\n", __func__, channel, xchan);
+
+	if (xchan < 0) {
+		if (xchan == -1)
+			cvmx_printf("%s: ERROR: channel %#x not recognized\n",
+				    __func__, channel);
+		return;
+	}
+
+	lutx.u64 = 0;
+	lutx.s.valid = 1;
+	lutx.s.pq_idx = pq_num;
+	lutx.s.queue_number = l2_l3_q_num;
+
+	csr_wr_node(node, CVMX_PKO_LUTX(xchan), lutx.u64);
+
+	if (debug)
+		debug("%s: channel %#x (compressed=%#x) mapped L2/L3 SQ=%u, PQ=%u\n",
+		      __func__, channel, xchan, l2_l3_q_num, pq_num);
+}
+
+/*
+ * @INTERNAL
+ * This function configures port queue scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param port_queue is the port queue number to be configured.
+ * @param mac_num is the mac number of the mac that will be tied to this port_queue.
+ */
+static void cvmx_pko_configure_port_queue(int node, int port_queue, int mac_num)
+{
+	cvmx_pko_l1_sqx_topology_t pko_l1_topology;
+	cvmx_pko_l1_sqx_shape_t pko_l1_shape;
+	cvmx_pko_l1_sqx_link_t pko_l1_link;
+
+	pko_l1_topology.u64 = 0;
+	pko_l1_topology.s.link = mac_num;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_TOPOLOGY(port_queue),
+		    pko_l1_topology.u64);
+
+	pko_l1_shape.u64 = 0;
+	pko_l1_shape.s.link = mac_num;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_SHAPE(port_queue), pko_l1_shape.u64);
+
+	pko_l1_link.u64 = 0;
+	pko_l1_link.s.link = mac_num;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_LINK(port_queue), pko_l1_link.u64);
+}
+
+/*
+ * @INTERNAL
+ * This function configures level 2 queues scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param queue is the level3 queue number to be configured.
+ * @param parent_queue is the parent queue at next level for this l3 queue.
+ * @param prio is this queue's priority in parent's scheduler.
+ * @param rr_quantum is this queue's round robin quantum value.
+ * @param child_base is the first child queue number in the static prioriy children.
+ * @param child_rr_prio is the round robin children priority.
+ */
+static void cvmx_pko_configure_l2_queue(int node, int queue, int parent_queue,
+					int prio, int rr_quantum,
+					int child_base, int child_rr_prio)
+{
+	cvmx_pko_l2_sqx_schedule_t pko_sq_sched;
+	cvmx_pko_l2_sqx_topology_t pko_child_topology;
+	cvmx_pko_l1_sqx_topology_t pko_parent_topology;
+
+	/* parent topology configuration */
+	pko_parent_topology.u64 =
+		csr_rd_node(node, CVMX_PKO_L1_SQX_TOPOLOGY(parent_queue));
+	pko_parent_topology.s.prio_anchor = child_base;
+	pko_parent_topology.s.rr_prio = child_rr_prio;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_TOPOLOGY(parent_queue),
+		    pko_parent_topology.u64);
+
+	if (debug > 1)
+		debug("CVMX_PKO_L1_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n",
+		      parent_queue, pko_parent_topology.s.prio_anchor,
+		      pko_parent_topology.s.link);
+
+	/* scheduler configuration for this sq in the parent queue */
+	pko_sq_sched.u64 = 0;
+	pko_sq_sched.s.prio = prio;
+	pko_sq_sched.s.rr_quantum = rr_quantum;
+	csr_wr_node(node, CVMX_PKO_L2_SQX_SCHEDULE(queue), pko_sq_sched.u64);
+
+	/* child topology configuration */
+	pko_child_topology.u64 = 0;
+	pko_child_topology.s.parent = parent_queue;
+	csr_wr_node(node, CVMX_PKO_L2_SQX_TOPOLOGY(queue),
+		    pko_child_topology.u64);
+}
+
+/*
+ * @INTERNAL
+ * This function configures level 3 queues scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param queue is the level3 queue number to be configured.
+ * @param parent_queue is the parent queue at next level for this l3 queue.
+ * @param prio is this queue's priority in parent's scheduler.
+ * @param rr_quantum is this queue's round robin quantum value.
+ * @param child_base is the first child queue number in the static prioriy children.
+ * @param child_rr_prio is the round robin children priority.
+ */
+static void cvmx_pko_configure_l3_queue(int node, int queue, int parent_queue,
+					int prio, int rr_quantum,
+					int child_base, int child_rr_prio)
+{
+	cvmx_pko_l3_sqx_schedule_t pko_sq_sched;
+	cvmx_pko_l3_sqx_topology_t pko_child_topology;
+	cvmx_pko_l2_sqx_topology_t pko_parent_topology;
+
+	/* parent topology configuration */
+	pko_parent_topology.u64 =
+		csr_rd_node(node, CVMX_PKO_L2_SQX_TOPOLOGY(parent_queue));
+	pko_parent_topology.s.prio_anchor = child_base;
+	pko_parent_topology.s.rr_prio = child_rr_prio;
+	csr_wr_node(node, CVMX_PKO_L2_SQX_TOPOLOGY(parent_queue),
+		    pko_parent_topology.u64);
+
+	if (debug > 1)
+		debug("CVMX_PKO_L2_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n",
+		      parent_queue, pko_parent_topology.s.prio_anchor,
+		      pko_parent_topology.s.parent);
+
+	/* scheduler configuration for this sq in the parent queue */
+	pko_sq_sched.u64 = 0;
+	pko_sq_sched.s.prio = prio;
+	pko_sq_sched.s.rr_quantum = rr_quantum;
+	csr_wr_node(node, CVMX_PKO_L3_SQX_SCHEDULE(queue), pko_sq_sched.u64);
+
+	/* child topology configuration */
+	pko_child_topology.u64 = 0;
+	pko_child_topology.s.parent = parent_queue;
+	csr_wr_node(node, CVMX_PKO_L3_SQX_TOPOLOGY(queue),
+		    pko_child_topology.u64);
+}
+
+/*
+ * @INTERNAL
+ * This function configures level 4 queues scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param queue is the level4 queue number to be configured.
+ * @param parent_queue is the parent queue at next level for this l4 queue.
+ * @param prio is this queue's priority in parent's scheduler.
+ * @param rr_quantum is this queue's round robin quantum value.
+ * @param child_base is the first child queue number in the static prioriy children.
+ * @param child_rr_prio is the round robin children priority.
+ */
+static void cvmx_pko_configure_l4_queue(int node, int queue, int parent_queue,
+					int prio, int rr_quantum,
+					int child_base, int child_rr_prio)
+{
+	cvmx_pko_l4_sqx_schedule_t pko_sq_sched;
+	cvmx_pko_l4_sqx_topology_t pko_child_topology;
+	cvmx_pko_l3_sqx_topology_t pko_parent_topology;
+
+	/* parent topology configuration */
+	pko_parent_topology.u64 =
+		csr_rd_node(node, CVMX_PKO_L3_SQX_TOPOLOGY(parent_queue));
+	pko_parent_topology.s.prio_anchor = child_base;
+	pko_parent_topology.s.rr_prio = child_rr_prio;
+	csr_wr_node(node, CVMX_PKO_L3_SQX_TOPOLOGY(parent_queue),
+		    pko_parent_topology.u64);
+
+	if (debug > 1)
+		debug("CVMX_PKO_L3_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n",
+		      parent_queue, pko_parent_topology.s.prio_anchor,
+		      pko_parent_topology.s.parent);
+
+	/* scheduler configuration for this sq in the parent queue */
+	pko_sq_sched.u64 = 0;
+	pko_sq_sched.s.prio = prio;
+	pko_sq_sched.s.rr_quantum = rr_quantum;
+	csr_wr_node(node, CVMX_PKO_L4_SQX_SCHEDULE(queue), pko_sq_sched.u64);
+
+	/* topology configuration */
+	pko_child_topology.u64 = 0;
+	pko_child_topology.s.parent = parent_queue;
+	csr_wr_node(node, CVMX_PKO_L4_SQX_TOPOLOGY(queue),
+		    pko_child_topology.u64);
+}
+
+/*
+ * @INTERNAL
+ * This function configures level 5 queues scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param queue is the level5 queue number to be configured.
+ * @param parent_queue is the parent queue at next level for this l5 queue.
+ * @param prio is this queue's priority in parent's scheduler.
+ * @param rr_quantum is this queue's round robin quantum value.
+ * @param child_base is the first child queue number in the static prioriy children.
+ * @param child_rr_prio is the round robin children priority.
+ */
+static void cvmx_pko_configure_l5_queue(int node, int queue, int parent_queue,
+					int prio, int rr_quantum,
+					int child_base, int child_rr_prio)
+{
+	cvmx_pko_l5_sqx_schedule_t pko_sq_sched;
+	cvmx_pko_l4_sqx_topology_t pko_parent_topology;
+	cvmx_pko_l5_sqx_topology_t pko_child_topology;
+
+	/* parent topology configuration */
+	pko_parent_topology.u64 =
+		csr_rd_node(node, CVMX_PKO_L4_SQX_TOPOLOGY(parent_queue));
+	pko_parent_topology.s.prio_anchor = child_base;
+	pko_parent_topology.s.rr_prio = child_rr_prio;
+	csr_wr_node(node, CVMX_PKO_L4_SQX_TOPOLOGY(parent_queue),
+		    pko_parent_topology.u64);
+
+	if (debug > 1)
+		debug("CVMX_PKO_L4_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n",
+		      parent_queue, pko_parent_topology.s.prio_anchor,
+		      pko_parent_topology.s.parent);
+
+	/* scheduler configuration for this sq in the parent queue */
+	pko_sq_sched.u64 = 0;
+	pko_sq_sched.s.prio = prio;
+	pko_sq_sched.s.rr_quantum = rr_quantum;
+	csr_wr_node(node, CVMX_PKO_L5_SQX_SCHEDULE(queue), pko_sq_sched.u64);
+
+	/* topology configuration */
+	pko_child_topology.u64 = 0;
+	pko_child_topology.s.parent = parent_queue;
+	csr_wr_node(node, CVMX_PKO_L5_SQX_TOPOLOGY(queue),
+		    pko_child_topology.u64);
+}
+
+/*
+ * @INTERNAL
+ * This function configures descriptor queues scheduling and topology parameters
+ * in hardware.
+ *
+ * @param node is to specify the node to which this configuration is applied.
+ * @param dq is the descriptor queue number to be configured.
+ * @param parent_queue is the parent queue at next level for this dq.
+ * @param prio is this queue's priority in parent's scheduler.
+ * @param rr_quantum is this queue's round robin quantum value.
+ * @param child_base is the first child queue number in the static prioriy children.
+ * @param child_rr_prio is the round robin children priority.
+ */
+static void cvmx_pko_configure_dq(int node, int dq, int parent_queue, int prio,
+				  int rr_quantum, int child_base,
+				  int child_rr_prio)
+{
+	cvmx_pko_dqx_schedule_t pko_dq_sched;
+	cvmx_pko_dqx_topology_t pko_dq_topology;
+	cvmx_pko_l5_sqx_topology_t pko_parent_topology;
+	cvmx_pko_dqx_wm_ctl_t pko_dq_wm_ctl;
+	unsigned long long parent_topology_reg;
+	char lvl;
+
+	if (debug)
+		debug("%s: dq %u parent %u child_base %u\n", __func__, dq,
+		      parent_queue, child_base);
+
+	if (__cvmx_pko3_sq_lvl_max() == CVMX_PKO_L5_QUEUES) {
+		parent_topology_reg = CVMX_PKO_L5_SQX_TOPOLOGY(parent_queue);
+		lvl = 5;
+	} else if (__cvmx_pko3_sq_lvl_max() == CVMX_PKO_L3_QUEUES) {
+		parent_topology_reg = CVMX_PKO_L3_SQX_TOPOLOGY(parent_queue);
+		lvl = 3;
+	} else {
+		return;
+	}
+
+	if (debug)
+		debug("%s: parent_topology_reg=%#llx\n", __func__,
+		      parent_topology_reg);
+
+	/* parent topology configuration */
+	pko_parent_topology.u64 = csr_rd_node(node, parent_topology_reg);
+	pko_parent_topology.s.prio_anchor = child_base;
+	pko_parent_topology.s.rr_prio = child_rr_prio;
+	csr_wr_node(node, parent_topology_reg, pko_parent_topology.u64);
+
+	if (debug > 1)
+		debug("CVMX_PKO_L%d_SQX_TOPOLOGY(%u): PRIO_ANCHOR=%u PARENT=%u\n",
+		      lvl, parent_queue, pko_parent_topology.s.prio_anchor,
+		      pko_parent_topology.s.parent);
+
+	/* scheduler configuration for this dq in the parent queue */
+	pko_dq_sched.u64 = 0;
+	pko_dq_sched.s.prio = prio;
+	pko_dq_sched.s.rr_quantum = rr_quantum;
+	csr_wr_node(node, CVMX_PKO_DQX_SCHEDULE(dq), pko_dq_sched.u64);
+
+	/* topology configuration */
+	pko_dq_topology.u64 = 0;
+	pko_dq_topology.s.parent = parent_queue;
+	csr_wr_node(node, CVMX_PKO_DQX_TOPOLOGY(dq), pko_dq_topology.u64);
+
+	/* configure for counting packets, not bytes at this level */
+	pko_dq_wm_ctl.u64 = 0;
+	pko_dq_wm_ctl.s.kind = 1;
+	pko_dq_wm_ctl.s.enable = 0;
+	csr_wr_node(node, CVMX_PKO_DQX_WM_CTL(dq), pko_dq_wm_ctl.u64);
+
+	if (debug > 1) {
+		pko_dq_sched.u64 = csr_rd_node(node, CVMX_PKO_DQX_SCHEDULE(dq));
+		pko_dq_topology.u64 =
+			csr_rd_node(node, CVMX_PKO_DQX_TOPOLOGY(dq));
+		debug("CVMX_PKO_DQX_TOPOLOGY(%u)PARENT=%u CVMX_PKO_DQX_SCHEDULE(%u) PRIO=%u Q=%u\n",
+		      dq, pko_dq_topology.s.parent, dq, pko_dq_sched.s.prio,
+		      pko_dq_sched.s.rr_quantum);
+	}
+}
+
+/*
+ * @INTERNAL
+ * The following structure selects the Scheduling Queue configuration
+ * routine for each of the supported levels.
+ * The initial content of the table will be setup in accordance
+ * to the specific SoC model and its implemented resources
+ */
+struct pko3_cfg_tab_s {
+	/* function pointer for to configure the given level, last=DQ */
+	struct {
+		u8 parent_level;
+		void (*cfg_sq_func)(int node, int queue, int parent_queue,
+				    int prio, int rr_quantum, int child_base,
+				    int child_rr_prio);
+		//XXX for debugging exagerated size
+	} lvl[256];
+};
+
+static const struct pko3_cfg_tab_s pko3_cn78xx_cfg = {
+	{ [CVMX_PKO_L2_QUEUES] = { CVMX_PKO_PORT_QUEUES,
+				   cvmx_pko_configure_l2_queue },
+	  [CVMX_PKO_L3_QUEUES] = { CVMX_PKO_L2_QUEUES,
+				   cvmx_pko_configure_l3_queue },
+	  [CVMX_PKO_L4_QUEUES] = { CVMX_PKO_L3_QUEUES,
+				   cvmx_pko_configure_l4_queue },
+	  [CVMX_PKO_L5_QUEUES] = { CVMX_PKO_L4_QUEUES,
+				   cvmx_pko_configure_l5_queue },
+	  [CVMX_PKO_DESCR_QUEUES] = { CVMX_PKO_L5_QUEUES,
+				      cvmx_pko_configure_dq } }
+};
+
+static const struct pko3_cfg_tab_s pko3_cn73xx_cfg = {
+	{ [CVMX_PKO_L2_QUEUES] = { CVMX_PKO_PORT_QUEUES,
+				   cvmx_pko_configure_l2_queue },
+	  [CVMX_PKO_L3_QUEUES] = { CVMX_PKO_L2_QUEUES,
+				   cvmx_pko_configure_l3_queue },
+	  [CVMX_PKO_DESCR_QUEUES] = { CVMX_PKO_L3_QUEUES,
+				      cvmx_pko_configure_dq } }
+};
+
+/*
+ * Configure Port Queue and its children Scheduler Queue
+ *
+ * Port Queues (a.k.a L1) are assigned 1-to-1 to MACs.
+ * L2 Scheduler Queues are used for specifying channels, and thus there
+ * could be multiple L2 SQs attached to a single L1 PQ, either in a
+ * fair round-robin scheduling, or with static and/or round-robin priorities.
+ *
+ * @param node on which to operate
+ * @param mac_num is the LMAC number to that is associated with the Port Queue,
+ * @param pq_num is the number of the L1 PQ attached to the MAC
+ *
+ * @returns 0 on success, -1 on failure.
+ */
+int cvmx_pko3_pq_config(unsigned int node, unsigned int mac_num,
+			unsigned int pq_num)
+{
+	char b1[10];
+
+	if (debug)
+		debug("%s: MAC%u -> %s\n", __func__, mac_num,
+		      __cvmx_pko3_sq_str(b1, CVMX_PKO_PORT_QUEUES, pq_num));
+
+	cvmx_pko_configure_port_queue(node, pq_num, mac_num);
+
+	return 0;
+}
+
+/*
+ * Configure L3 through L5 Scheduler Queues and Descriptor Queues
+ *
+ * The Scheduler Queues in Levels 3 to 5 and Descriptor Queues are
+ * configured one-to-one or many-to-one to a single parent Scheduler
+ * Queues. The level of the parent SQ is specified in an argument,
+ * as well as the number of childer to attach to the specific parent.
+ * The children can have fair round-robin or priority-based scheduling
+ * when multiple children are assigned a single parent.
+ *
+ * @param node on which to operate
+ * @param child_level  is the level of the child queue
+ * @param parent_queue is the number of the parent Scheduler Queue
+ * @param child_base is the number of the first child SQ or DQ to assign to
+ * @param child_count is the number of consecutive children to assign
+ * @param stat_prio_count is the priority setting for the children L2 SQs
+ *
+ * If <stat_prio_count> is -1, the Ln children will have equal Round-Robin
+ * relationship with eachother. If <stat_prio_count> is 0, all Ln children
+ * will be arranged in Weighted-Round-Robin, with the first having the most
+ * precedence. If <stat_prio_count> is between 1 and 8, it indicates how
+ * many children will have static priority settings (with the first having
+ * the most precedence), with the remaining Ln children having WRR scheduling.
+ *
+ * @returns 0 on success, -1 on failure.
+ *
+ * Note: this function supports the configuration of node-local unit.
+ */
+int cvmx_pko3_sq_config_children(unsigned int node,
+				 enum cvmx_pko3_level_e child_level,
+				 unsigned int parent_queue,
+				 unsigned int child_base,
+				 unsigned int child_count, int stat_prio_count)
+{
+	enum cvmx_pko3_level_e parent_level;
+	unsigned int num_elem = 0;
+	unsigned int rr_quantum, rr_count;
+	unsigned int child, prio, rr_prio;
+	const struct pko3_cfg_tab_s *cfg_tbl = NULL;
+	char b1[10], b2[10];
+
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX)) {
+		num_elem = NUM_ELEMENTS(pko3_cn78xx_cfg.lvl);
+		cfg_tbl = &pko3_cn78xx_cfg;
+	}
+	if (OCTEON_IS_MODEL(OCTEON_CN73XX) || OCTEON_IS_MODEL(OCTEON_CNF75XX)) {
+		num_elem = NUM_ELEMENTS(pko3_cn73xx_cfg.lvl);
+		cfg_tbl = &pko3_cn73xx_cfg;
+	}
+
+	if (!cfg_tbl || child_level >= num_elem) {
+		cvmx_printf("ERROR: %s: model or level %#x invalid\n", __func__,
+			    child_level);
+		return -1;
+	}
+
+	parent_level = cfg_tbl->lvl[child_level].parent_level;
+
+	if (!cfg_tbl->lvl[child_level].cfg_sq_func ||
+	    cfg_tbl->lvl[child_level].parent_level == 0) {
+		cvmx_printf("ERROR: %s: queue level %#x invalid\n", __func__,
+			    child_level);
+		return -1;
+	}
+
+	/* First static priority is 0 - top precedence */
+	prio = 0;
+
+	if (stat_prio_count > (signed int)child_count)
+		stat_prio_count = child_count;
+
+	/* Valid PRIO field is 0..9, limit maximum static priorities */
+	if (stat_prio_count > 9)
+		stat_prio_count = 9;
+
+	/* Special case of a single child */
+	if (child_count == 1) {
+		rr_count = 0;
+		rr_prio = 0xF;
+		/* Special case for Fair-RR */
+	} else if (stat_prio_count < 0) {
+		rr_count = child_count;
+		rr_prio = 0;
+	} else {
+		rr_count = child_count - stat_prio_count;
+		rr_prio = stat_prio_count;
+	}
+
+	/* Compute highest RR_QUANTUM */
+	if (stat_prio_count > 0)
+		rr_quantum = CVMX_PKO3_RR_QUANTUM_MIN * rr_count;
+	else
+		rr_quantum = CVMX_PKO3_RR_QUANTUM_MIN;
+
+	if (debug)
+		debug("%s: Parent %s child_base %u rr_pri %u\n", __func__,
+		      __cvmx_pko3_sq_str(b1, parent_level, parent_queue),
+		      child_base, rr_prio);
+
+	/* Parent is configured with child */
+
+	for (child = child_base; child < (child_base + child_count); child++) {
+		if (debug)
+			debug("%s: Child %s of %s prio %u rr_quantum %#x\n",
+			      __func__,
+			      __cvmx_pko3_sq_str(b1, child_level, child),
+			      __cvmx_pko3_sq_str(b2, parent_level,
+						 parent_queue),
+			      prio, rr_quantum);
+
+		cfg_tbl->lvl[child_level].cfg_sq_func(node, child, parent_queue,
+						      prio, rr_quantum,
+						      child_base, rr_prio);
+
+		if (prio < rr_prio)
+			prio++;
+		else if (stat_prio_count > 0)
+			rr_quantum -= CVMX_PKO3_RR_QUANTUM_MIN;
+	} /* for child */
+
+	return 0;
+}
+
+/**
+ * Convert bitrate and burst size to SQx_xIR register values
+ *
+ * @INTERNAL
+ *
+ * Common function to convert bit-rate (ie kilo-bits-per-sec)
+ * and maximum burst (in bytes) values to PKO shaper register
+ * format, that is a short-float type, with divisor.
+ *
+ * @param tclk is the time-wheel clock for the specific shaper
+ * @param reg is a pointer to a register structure
+ * @param rate_kbips is the requested bit rate in kilobits/sec
+ * @param burst_bytes is the size of maximum burst in bytes
+ *
+ * @return A negative number means the transfer rate could
+ * not be set within acceptable tolerance, and the actual
+ * error in PPM is the negative of the returned value.
+ * A positive value indicates that the bit rate was set
+ * within acceptable tolerance, but the burst rate had an
+ * error, which is returned in PPM.
+ * A value of 0 means both measures were set within tolerance.
+ *
+ * Note that the bust error could be as a result of this function
+ * enforcing the minimum MTU as the minimum burst size allowed.
+ *
+ */
+static int cvmx_pko3_shaper_rate_compute(unsigned long tclk,
+					 cvmx_pko_l1_sqx_cir_t *reg,
+					 unsigned long rate_kbips,
+					 unsigned int burst_bytes)
+{
+	const unsigned int max_exp = 12;       /* maximum exponent */
+	const unsigned int tock_bytes_exp = 0; /* tock rate in bytes */
+	long long burst_v, rate_v;
+	unsigned long long rate_tocks, burst_tocks;
+	unsigned long min_burst;
+	unsigned int div_exp, mant, exp;
+	unsigned long long tmp, fmax;
+
+	if (debug)
+		debug("%s: tclk=%lu, rate=%lu kbps, burst=%u bytes\n", __func__,
+		      tclk, rate_kbips, burst_bytes);
+
+	/* Convert API args into tocks: PSE native units */
+	tmp = (1 << (3 + tock_bytes_exp)) - 1;
+	tmp += rate_kbips;
+	rate_tocks = (1000ULL * tmp) >> (3 + tock_bytes_exp);
+	tmp = (1 << tock_bytes_exp) - 1;
+	burst_tocks = (burst_bytes + tmp) >> tock_bytes_exp;
+
+	/* Compute largest short-float that fits in register fields */
+	fmax = CVMX_SHOFT_TO_U64((1 << CVMX_SHOFT_MANT_BITS) - 1, max_exp);
+
+	/* Find the biggest divider that has the short float fit */
+	for (div_exp = 0; div_exp <= max_exp; div_exp++) {
+		tmp = ((rate_tocks << div_exp) + (tclk / 2)) / tclk;
+		if (tmp > fmax) {
+			if (div_exp > 0)
+				div_exp--;
+			break;
+		}
+	}
+	/* Make sure divider, rate are within valid range */
+	if (div_exp > max_exp) {
+		/* Minimum reached */
+		div_exp = max_exp;
+	} else if (div_exp == 0) {
+		/* Maximum reached */
+		if ((rate_tocks / tclk) > fmax)
+			rate_tocks = fmax * tclk;
+	}
+	/* Store common divider */
+	reg->s.rate_divider_exponent = div_exp;
+
+	/* Burst register is the maximum accumulated credit count
+	 * in bytes, which must not be less then the MTU, and
+	 * should not be less than RATE/Tclk
+	 */
+
+	/* Find the minimum burst size needed for rate (burst ~ 4x rate) */
+	min_burst = (rate_tocks << (div_exp + 4)) / tclk;
+
+	/* Apply the minimum */
+	if (burst_tocks < min_burst)
+		burst_tocks = min_burst;
+
+	/* Calculate the rate short float */
+	tmp = (rate_tocks << (div_exp + 8)) / tclk;
+	CVMX_SHOFT_FROM_U64(tmp, mant, exp);
+	reg->s.rate_mantissa = mant;
+	reg->s.rate_exponent = exp - 8;
+
+	/* Calculate the BURST short float */
+	tmp = (burst_tocks << 8);
+	CVMX_SHOFT_FROM_U64(tmp, mant, exp);
+	reg->s.burst_mantissa = mant;
+	reg->s.burst_exponent = exp - 8 - 1;
+
+	if (debug)
+		debug("%s: RATE=%llu BURST=%llu DIV_EXP=%d\n", __func__,
+		      CVMX_SHOFT_TO_U64(reg->s.rate_mantissa,
+					reg->s.rate_exponent),
+		      CVMX_SHOFT_TO_U64(reg->s.burst_mantissa,
+					(reg->s.burst_exponent + 1)),
+		      div_exp);
+
+	/* Validate the resulting rate */
+	rate_v = CVMX_SHOFT_TO_U64(reg->s.rate_mantissa, reg->s.rate_exponent) *
+		 tclk;
+	/* Convert to kbips for comaring with argument */
+	rate_v = (rate_v << (3 + tock_bytes_exp)) / 1000ULL;
+	/* Finally apply divider for best accuracy */
+	rate_v >>= div_exp;
+
+	burst_v = CVMX_SHOFT_TO_U64(reg->s.burst_mantissa,
+				    (reg->s.burst_exponent + 1));
+	/* Convert in additional bytes as in argument */
+	burst_v = burst_v << (tock_bytes_exp);
+
+	if (debug)
+		debug("%s: result rate=%'llu kbips burst=%llu bytes\n",
+		      __func__, rate_v, burst_v);
+
+	/* Compute error in parts-per-million */
+	rate_v = abs(rate_v - rate_kbips);
+	burst_v = abs(burst_v - burst_bytes);
+
+	if (debug)
+		debug("%s: diff rate=%llu burst=%llu ppm\n", __func__, rate_v,
+		      burst_v);
+
+	rate_v = (rate_v * 1000000ULL) / rate_kbips;
+	if (burst_bytes > 0)
+		burst_v = (burst_v * 1000000ULL) / burst_bytes;
+	else
+		burst_v = 0;
+
+	if (debug)
+		debug("%s: error rate=%llu burst=%llu ppm\n", __func__, rate_v,
+		      burst_v);
+
+	/* Allow 1% error for CIR/PIR, and 5% for BURST */
+	if (rate_v > 10000)
+		return -rate_v;
+	if (burst_v > 50000)
+		return burst_v;
+
+	return 0;
+}
+
+/**
+ * Configure per-port CIR rate limit parameters
+ *
+ * This function configures rate limit at the L1/PQ level,
+ * i.e. for an entire MAC or physical port.
+ *
+ * @param node The OCI node where the target port is located
+ * @param pq_num The L1/PQ queue number for this setting
+ * @param rate_kbips The desired throughput in kilo-bits-per-second
+ * @param burst_bytes The size of a burst in bytes, at least MTU
+ *
+ * @return Returns zero if both settings applied within allowed tolerance,
+ * otherwise the error is returned in parts-per-million.
+ * 'rate_bps" error is e negative number, otherwise 'birst_rate' error
+ * is returned as a positive integer.
+ */
+int cvmx_pko3_port_cir_set(unsigned int node, unsigned int pq_num,
+			   unsigned long rate_kbips, unsigned int burst_bytes,
+			   int adj_bytes)
+{
+	unsigned long tclk;
+	cvmx_pko_l1_sqx_cir_t sqx_cir;
+	cvmx_pko_l1_sqx_shape_t shape;
+	int rc;
+
+	if (debug)
+		debug("%s: pq=%u rate=%lu kbps, burst=%u bytes\n", __func__,
+		      pq_num, rate_kbips, burst_bytes);
+
+	sqx_cir.u64 = 0;
+
+	/* When rate == 0, disable the shaper */
+	if (rate_kbips == 0ULL) {
+		sqx_cir.s.enable = 0;
+		csr_wr_node(node, CVMX_PKO_L1_SQX_CIR(pq_num), sqx_cir.u64);
+		return 0;
+	}
+	/* Compute time-wheel frequency */
+	tclk = cvmx_pko3_pq_tw_clock_rate_node(node);
+
+	/* Compute shaper values */
+	rc = cvmx_pko3_shaper_rate_compute(tclk, &sqx_cir, rate_kbips,
+					   burst_bytes);
+
+	/* Apply new settings */
+	sqx_cir.s.enable = 1;
+	sqx_cir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent;
+	sqx_cir.s.rate_mantissa = sqx_cir.s.rate_mantissa;
+	sqx_cir.s.rate_exponent = sqx_cir.s.rate_exponent;
+	sqx_cir.s.burst_mantissa = sqx_cir.s.burst_mantissa;
+	sqx_cir.s.burst_exponent = sqx_cir.s.burst_exponent - 1;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_CIR(pq_num), sqx_cir.u64);
+
+	shape.u64 = csr_rd_node(node, CVMX_PKO_L1_SQX_SHAPE(pq_num));
+	shape.s.adjust = adj_bytes;
+	csr_wr_node(node, CVMX_PKO_L1_SQX_SHAPE(pq_num), shape.u64);
+
+	return rc;
+}
+
+/**
+ * Configure per-queue CIR rate limit parameters
+ *
+ * This function configures rate limit at the descriptor queue level.
+ *
+ * @param node The OCI node where the target port is located
+ * @param dq_num The descriptor queue number for this setting
+ * @param rate_kbips The desired throughput in kilo-bits-per-second
+ * @param burst_bytes The size of a burst in bytes, at least MTU
+ *
+ * @return Returns zero if both settings applied within allowed tolerance,
+ * otherwise the error is returned in parts-per-million.
+ * 'rate_bps" error is a negative number, otherwise 'birst_rate' error
+ * is returned as a positive integer.
+ */
+int cvmx_pko3_dq_cir_set(unsigned int node, unsigned int dq_num,
+			 unsigned long rate_kbips, unsigned int burst_bytes)
+{
+	unsigned long tclk;
+	cvmx_pko_l1_sqx_cir_t sqx_cir;
+	cvmx_pko_dqx_cir_t dqx_cir;
+	int rc;
+
+	dq_num &= cvmx_pko3_num_level_queues(CVMX_PKO_DESCR_QUEUES) - 1;
+	if (debug)
+		debug("%s: dq=%u rate=%lu kbps, burst=%u bytes\n", __func__,
+		      dq_num, rate_kbips, burst_bytes);
+
+	dqx_cir.u64 = 0;
+
+	/* When rate == 0, disable the shaper */
+	if (rate_kbips == 0ULL) {
+		dqx_cir.s.enable = 0;
+		csr_wr_node(node, CVMX_PKO_DQX_CIR(dq_num), dqx_cir.u64);
+		return 0;
+	}
+	/* Compute time-wheel frequency */
+	tclk = cvmx_pko3_dq_tw_clock_rate_node(node);
+
+	/* Compute shaper values */
+	rc = cvmx_pko3_shaper_rate_compute(tclk, &sqx_cir, rate_kbips,
+					   burst_bytes);
+
+	/* Apply new settings */
+	dqx_cir.s.enable = 1;
+	dqx_cir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent;
+	dqx_cir.s.rate_mantissa = sqx_cir.s.rate_mantissa;
+	dqx_cir.s.rate_exponent = sqx_cir.s.rate_exponent;
+	dqx_cir.s.burst_mantissa = sqx_cir.s.burst_mantissa;
+	dqx_cir.s.burst_exponent = sqx_cir.s.burst_exponent - 1;
+	csr_wr_node(node, CVMX_PKO_DQX_CIR(dq_num), dqx_cir.u64);
+
+	return rc;
+}
+
+/**
+ * Configure per-queue PIR rate limit parameters
+ *
+ * This function configures rate limit at the descriptor queue level.
+ *
+ * @param node The OCI node where the target port is located
+ * @param dq_num The descriptor queue number for this setting
+ * @param rate_kbips The desired throughput in kilo-bits-per-second
+ * @param burst_bytes The size of a burst in bytes, at least MTU
+ *
+ * @return Returns zero if both settings applied within allowed tolerance,
+ * otherwise the error is returned in parts-per-million.
+ * 'rate_bps" error is a negative number, otherwise 'birst_rate' error
+ * is returned as a positive integer.
+ */
+int cvmx_pko3_dq_pir_set(unsigned int node, unsigned int dq_num,
+			 unsigned long rate_kbips, unsigned int burst_bytes)
+{
+	unsigned long tclk;
+	cvmx_pko_l1_sqx_cir_t sqx_cir;
+	cvmx_pko_dqx_pir_t dqx_pir;
+	int rc;
+
+	dq_num &= cvmx_pko3_num_level_queues(CVMX_PKO_DESCR_QUEUES) - 1;
+	if (debug)
+		debug("%s: dq=%u rate=%lu kbps, burst=%u bytes\n", __func__,
+		      dq_num, rate_kbips, burst_bytes);
+
+	dqx_pir.u64 = 0;
+
+	/* When rate == 0, disable the shaper */
+	if (rate_kbips == 0ULL) {
+		dqx_pir.s.enable = 0;
+		csr_wr_node(node, CVMX_PKO_DQX_PIR(dq_num), dqx_pir.u64);
+		return 0;
+	}
+	/* Compute time-wheel frequency */
+	tclk = cvmx_pko3_dq_tw_clock_rate_node(node);
+
+	/* Compute shaper values */
+	rc = cvmx_pko3_shaper_rate_compute(tclk, &sqx_cir, rate_kbips,
+					   burst_bytes);
+
+	/* Apply new settings */
+	dqx_pir.s.enable = 1;
+	dqx_pir.s.rate_divider_exponent = sqx_cir.s.rate_divider_exponent;
+	dqx_pir.s.rate_mantissa = sqx_cir.s.rate_mantissa;
+	dqx_pir.s.rate_exponent = sqx_cir.s.rate_exponent;
+	dqx_pir.s.burst_mantissa = sqx_cir.s.burst_mantissa;
+	dqx_pir.s.burst_exponent = sqx_cir.s.burst_exponent - 1;
+	csr_wr_node(node, CVMX_PKO_DQX_PIR(dq_num), dqx_pir.u64);
+
+	return rc;
+}
+
+/**
+ * Configure per-queue treatment of excess traffic
+ *
+ * The default and most sensible behavior is to stall the packets
+ * colored Red (i.e. exceeding the PIR rate in full 3-color mode).
+ * There is also the option to discard excess traffic, which is
+ * the desired action for some applications that do not rely on
+ * back-pressure flow control.
+ * The shaper may be programmed to pass the RED packets onwards,
+ * which may be useful it the color is translated to a change
+ * in packet priority on egress.
+ *
+ * @param node The OCI node where the target port is located
+ * @param dq_num The descriptor queue number for this setting
+ * @param red_act The action required for all packets in excess of PIR
+ * @param len_adjust A 2's complement 8 bit value to add/subtract from
+ * packet length for the purpose of shaping calculations, e.g.
+ * a value of -14 will subtract the length of the Ethernet header
+ * and hence only account IP packet size.
+ *
+ * @return N/A
+ */
+void cvmx_pko3_dq_red(unsigned int node, unsigned int dq_num,
+		      red_action_t red_act, int8_t len_adjust)
+{
+	cvmx_pko_dqx_shape_t dqx_shape;
+
+	dq_num &= cvmx_pko3_num_level_queues(CVMX_PKO_DESCR_QUEUES) - 1;
+	dqx_shape.u64 = 0;
+
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX_PASS1_X)) {
+		if (len_adjust < 0)
+			len_adjust = 0;
+	}
+	dqx_shape.s.adjust = len_adjust;
+
+	switch (red_act) {
+	default:
+	case CVMX_PKO3_SHAPE_RED_STALL:
+		dqx_shape.s.red_algo = 0x0;
+		break;
+	case CVMX_PKO3_SHAPE_RED_DISCARD:
+		dqx_shape.s.red_algo = 0x3;
+		break;
+	case CVMX_PKO3_SHAPE_RED_PASS:
+		dqx_shape.s.red_algo = 0x1;
+		break;
+	}
+	csr_wr_node(node, CVMX_PKO_DQX_SHAPE(dq_num), dqx_shape.u64);
+}
Signature · 1 line
2.35.1
#33 lore raw

PATCH 37/52 mips: octeon: Add cvmx-pko3-compat.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-pko3-compat.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 arch/mips/mach-octeon/cvmx-pko3-compat.c | 656 +++++++++++++++++++++++
 1 file changed, 656 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-compat.c
arch/mips/mach-octeon/cvmx-pko3-compat.c new file +656 -0
new file mode 100644
index 000000000000..3e142322dbfb
@@ -0,0 +1,656 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ *
+ */
+
+#include <errno.h>
+#include <log.h>
+#include <time.h>
+#include <linux/delay.h>
+
+#include <mach/cvmx-regs.h>
+#include <mach/cvmx-csr.h>
+#include <mach/cvmx-bootmem.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+#include <mach/cvmx-pcie.h>
+#include <mach/cvmx-coremask.h>
+
+#include <mach/cvmx-agl-defs.h>
+#include <mach/cvmx-bgxx-defs.h>
+#include <mach/cvmx-ciu-defs.h>
+#include <mach/cvmx-gmxx-defs.h>
+#include <mach/cvmx-gserx-defs.h>
+#include <mach/cvmx-ilk-defs.h>
+#include <mach/cvmx-ipd-defs.h>
+#include <mach/cvmx-pcsx-defs.h>
+#include <mach/cvmx-pcsxx-defs.h>
+#include <mach/cvmx-pki-defs.h>
+#include <mach/cvmx-pko-defs.h>
+#include <mach/cvmx-xcv-defs.h>
+
+#include <mach/cvmx-scratch.h>
+#include <mach/cvmx-hwfau.h>
+#include <mach/cvmx-fau.h>
+
+#include <mach/cvmx-hwpko.h>
+#include <mach/cvmx-ilk.h>
+#include <mach/cvmx-pki.h>
+#include <mach/cvmx-pko3.h>
+#include <mach/cvmx-pko3-queue.h>
+#include <mach/cvmx-pko3-resources.h>
+
+#include <mach/cvmx-helper.h>
+#include <mach/cvmx-helper-board.h>
+#include <mach/cvmx-helper-cfg.h>
+
+#include <mach/cvmx-helper-bgx.h>
+#include <mach/cvmx-helper-cfg.h>
+#include <mach/cvmx-helper-util.h>
+#include <mach/cvmx-helper-pki.h>
+
+/* #undef CVMX_ENABLE_PARAMETER_CHECKING */
+/* #define CVMX_ENABLE_PARAMETER_CHECKING 1 */
+/* #define	__PKO3_NATIVE_PTR */
+
+static inline u64 cvmx_pko3_legacy_paddr(unsigned int node, u64 addr)
+{
+	u64 paddr;
+
+	paddr = node;
+	paddr = (addr & ((1ull << 40) - 1)) | (paddr << 40);
+	return paddr;
+}
+
+#if CVMX_ENABLE_PARAMETER_CHECKING
+/**
+ * @INTERNAL
+ *
+ * Verify the integrity of a legacy buffer link pointer,
+ *
+ * Note that the IPD/PIP/PKO hardware would sometimes
+ * round-up the buf_ptr->size field of the last buffer in a chain  to the next
+ * cache line size, so the sum of buf_ptr->size
+ * fields for a packet may exceed total_bytes by up to 127 bytes.
+ *
+ * @returns 0 on success, a negative number on error.
+ */
+static int cvmx_pko3_legacy_bufptr_validate(cvmx_buf_ptr_t buf_ptr,
+					    unsigned int gather,
+					    unsigned int buffers,
+					    unsigned int total_bytes)
+{
+	unsigned int node = cvmx_get_node_num();
+	unsigned int segs = 0, bytes = 0;
+	unsigned int phys_addr;
+	cvmx_buf_ptr_t ptr;
+	int delta;
+
+	if (buffers == 0) {
+		return -1;
+	} else if (buffers == 1) {
+		delta = buf_ptr.s.size - total_bytes;
+		if (delta < 0 || delta > 127)
+			return -2;
+	} else if (gather) {
+		cvmx_buf_ptr_t *vptr;
+		/* Validate gather list */
+		if (buf_ptr.s.size < buffers)
+			return -3;
+		phys_addr = cvmx_pko3_legacy_paddr(node, buf_ptr.s.addr);
+		vptr = cvmx_phys_to_ptr(phys_addr);
+		for (segs = 0; segs < buffers; segs++)
+			bytes += vptr[segs].s.size;
+		delta = bytes - total_bytes;
+		if (delta < 0 || delta > 127)
+			return -4;
+	} else {
+		void *vptr;
+		/* Validate linked buffers */
+		ptr = buf_ptr;
+		for (segs = 0; segs < buffers; segs++) {
+			bytes += ptr.s.size;
+			phys_addr = cvmx_pko3_legacy_paddr(node, ptr.s.addr);
+			vptr = cvmx_phys_to_ptr(phys_addr);
+			memcpy(&ptr, vptr - sizeof(u64), sizeof(u64));
+		}
+		delta = bytes - total_bytes;
+		if (delta < 0 || delta > 127)
+			return -5;
+	}
+	return 0;
+}
+#endif /* CVMX_ENABLE_PARAMETER_CHECKING */
+
+/*
+ * @INTERNAL
+ *
+ * Implementation note:
+ * When the packet is sure to not need a jump_buf,
+ * it will be written directly into cvmseg.
+ * When the packet might not fit into cvmseg with all
+ * of its descriptors, a jump_buf is allocated a priori,
+ * and only header is first placed into cvmseg, all other
+ * descriptors are placed into jump_buf, and finally
+ * the PKO_SEND_JUMP_S is written to cvmseg.
+ * This is because if there are no EXT or TSO descriptors,
+ * then HDR must be first, and JMP second and that is all
+ * that should go into cvmseg.
+ */
+struct __cvmx_pko3_legacy_desc {
+	u64 *cmd_words;
+	u64 *jump_buf_base_ptr;
+	unsigned short word_count;
+	short last_pool;
+	u8 port_node;
+	u8 aura_node;
+	u8 jump_buf_size;
+};
+
+/**
+ * @INTERNAL
+ *
+ * Add a subdescriptor into a command buffer,
+ * and handle command-buffer overflow by allocating a JUMP_s buffer
+ * from PKO3 internal AURA.
+ */
+static int __cvmx_pko3_cmd_subdc_add(struct __cvmx_pko3_legacy_desc *desc,
+				     u64 subdc)
+{
+	/* SEND_JUMP_S missing on Pass1.X */
+	if (desc->word_count >= 15) {
+		printf("%s: ERROR: too many segments\n", __func__);
+		return -EBADF;
+	}
+
+	/* Handle small commands simply */
+	if (cvmx_likely(!desc->jump_buf_base_ptr)) {
+		desc->cmd_words[desc->word_count] = subdc;
+		(desc->word_count)++;
+		return desc->word_count;
+	}
+
+	if (cvmx_unlikely(desc->jump_buf_size >= 255))
+		return -ENOMEM;
+
+	desc->jump_buf_base_ptr[desc->jump_buf_size++] = subdc;
+
+	return desc->word_count + desc->jump_buf_size;
+}
+
+/**
+ * @INTERNAL
+ *
+ * Finalize command buffer
+ *
+ * @returns: number of command words in command buffer and jump buffer
+ * or negative number on error.
+ */
+
+static int __cvmx_pko3_cmd_done(struct __cvmx_pko3_legacy_desc *desc)
+{
+	short pko_aura;
+	cvmx_pko_buf_ptr_t jump_s;
+	cvmx_pko_send_aura_t aura_s;
+
+	/* no jump buffer, nothing to do */
+	if (!desc->jump_buf_base_ptr)
+		return desc->word_count;
+
+	desc->word_count++;
+
+	/* Verify number of words is 15 */
+	if (desc->word_count != 2) {
+		printf("ERROR: %s: internal error, word_count=%d\n", __func__,
+		       desc->word_count);
+		return -EINVAL;
+	}
+
+	/* Add SEND_AURA_S at the end of jump_buf */
+	pko_aura = __cvmx_pko3_aura_get(desc->port_node);
+
+	aura_s.u64 = 0;
+	aura_s.s.aura = pko_aura;
+	aura_s.s.offset = 0;
+	aura_s.s.alg = AURAALG_NOP;
+	aura_s.s.subdc4 = CVMX_PKO_SENDSUBDC_AURA;
+
+	desc->jump_buf_base_ptr[desc->jump_buf_size++] = aura_s.u64;
+
+	/* Add SEND_JUMPS to point to jump_buf */
+	jump_s.u64 = 0;
+	jump_s.s.subdc3 = CVMX_PKO_SENDSUBDC_JUMP;
+	jump_s.s.addr = cvmx_ptr_to_phys(desc->jump_buf_base_ptr);
+	jump_s.s.i = 1; /* F=1: Free this buffer when done */
+	jump_s.s.size = desc->jump_buf_size;
+	desc->cmd_words[1] = jump_s.u64;
+
+	return desc->word_count + desc->jump_buf_size;
+}
+
+/**
+ * @INTERNAL
+ *
+ * Handle buffer pools for PKO legacy transmit operation
+ */
+static inline int cvmx_pko3_legacy_pool(struct __cvmx_pko3_legacy_desc *desc,
+					int pool)
+{
+	cvmx_pko_send_aura_t aura_s;
+	unsigned int aura;
+
+	if (cvmx_unlikely(desc->last_pool == pool))
+		return 0;
+
+	aura = desc->aura_node << 10; /* LAURA=AURA[0..9] */
+	aura |= pool;
+
+	if (cvmx_likely(desc->last_pool < 0)) {
+		cvmx_pko_send_hdr_t *hdr_s;
+
+		hdr_s = (void *)&desc->cmd_words[0];
+		/* Create AURA from legacy pool (assume LAURA==POOL */
+		hdr_s->s.aura = aura;
+		desc->last_pool = pool;
+		return 0;
+	}
+
+	aura_s.u64 = 0;
+	aura_s.s.subdc4 = CVMX_PKO_SENDSUBDC_AURA;
+	aura_s.s.offset = 0;
+	aura_s.s.alg = AURAALG_NOP;
+	aura |= pool;
+	aura_s.s.aura = aura;
+	desc->last_pool = pool;
+	return __cvmx_pko3_cmd_subdc_add(desc, aura_s.u64);
+}
+
+/**
+ * @INTERNAL
+ *
+ * Backward compatibility for packet transmission using legacy PKO command.
+ *
+ * NOTE: Only supports output on node-local ports.
+ *
+ * TBD: Could embed destination node in extended DQ number.
+ */
+cvmx_pko_return_value_t
+cvmx_pko3_legacy_xmit(unsigned int dq, cvmx_pko_command_word0_t pko_command,
+		      cvmx_buf_ptr_t packet, u64 addr, bool tag_sw)
+{
+	cvmx_pko_query_rtn_t pko_status;
+	cvmx_pko_send_hdr_t *hdr_s;
+	struct __cvmx_pko3_legacy_desc desc;
+	u8 *data_ptr;
+	unsigned int node, seg_cnt;
+	int res;
+	cvmx_buf_ptr_pki_t bptr;
+
+	seg_cnt = pko_command.s.segs;
+	desc.cmd_words = cvmx_pko3_cvmseg_addr();
+
+	/* Allocate from local aura, assume all old-pools are local */
+	node = cvmx_get_node_num();
+	desc.aura_node = node;
+
+	/* Derive destination node from dq */
+	desc.port_node = dq >> 10;
+	dq &= (1 << 10) - 1;
+
+	desc.word_count = 1;
+	desc.last_pool = -1;
+
+	/* For small packets, write descriptors directly to CVMSEG
+	 * but for longer packets use jump_buf
+	 */
+	if (seg_cnt < 7 || OCTEON_IS_MODEL(OCTEON_CN78XX_PASS1_X)) {
+		desc.jump_buf_size = 0;
+		desc.jump_buf_base_ptr = NULL;
+	} else {
+		unsigned int pko_aura = __cvmx_pko3_aura_get(desc.port_node);
+
+		cvmx_fpa3_gaura_t aura =
+			__cvmx_fpa3_gaura(pko_aura >> 10, pko_aura & 0x3ff);
+
+		/* Allocate from internal AURA, size is 4KiB */
+		desc.jump_buf_base_ptr = cvmx_fpa3_alloc(aura);
+
+		if (!desc.jump_buf_base_ptr)
+			return -ENOMEM;
+		desc.jump_buf_size = 0;
+	}
+
+	/* Native buffer-pointer for error checiing */
+	bptr.u64 = packet.u64;
+
+#if CVMX_ENABLE_PARAMETER_CHECKING
+	if (seg_cnt == 1 && bptr.size == pko_command.s.total_bytes) {
+		/*
+		 * Special case for native buffer pointer:
+		 * This is the only case where the native pointer-style can be
+		 * automatically identified, that is when an entire packet
+		 * fits into a single buffer by the PKI.
+		 * The use of the native buffers with this function
+		 * should be avoided.
+		 */
+		debug("%s: WARNING: Native buffer-pointer\n", __func__);
+	} else {
+		/* The buffer ptr is assume to be received in legacy format */
+		res = cvmx_pko3_legacy_bufptr_validate(
+			packet, pko_command.s.gather, pko_command.s.segs,
+			pko_command.s.total_bytes);
+		if (res < 0) {
+			debug("%s: ERROR: Not a valid packet pointer <%d>\n",
+			      __func__, res);
+			return CVMX_PKO_CMD_QUEUE_INIT_ERROR;
+		}
+	}
+#endif /* CVMX_ENABLE_PARAMETER_CHECKING */
+
+	/* Squash warnings */
+	(void)bptr;
+
+	/*** Translate legacy PKO fields into PKO3 PKO_SEND_HDR_S ***/
+
+	/* PKO_SEND_HDR_S is alwasy the first word in the command */
+	hdr_s = (void *)&desc.cmd_words[0];
+	hdr_s->u64 = 0;
+
+	/* Copy total packet size */
+	hdr_s->s.total = pko_command.s.total_bytes;
+
+	/* Endianness */
+	hdr_s->s.le = pko_command.s.le;
+
+	/* N2 is the same meaning */
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX_PASS1_X))
+		hdr_s->s.n2 = 0; /* L2 allocate everything */
+	else
+		hdr_s->s.n2 = pko_command.s.n2;
+
+	/* DF bit has the same meaning */
+	hdr_s->s.df = pko_command.s.dontfree;
+
+	/* II bit has the same meaning */
+	hdr_s->s.ii = pko_command.s.ignore_i;
+
+	/* non-zero IP header offset requires L3/L4 checksum calculation */
+	if (cvmx_unlikely(pko_command.s.ipoffp1 > 0)) {
+		u8 ipoff, ip0, l4_proto = 0;
+
+		/* Get data pointer for header inspection below */
+		if (pko_command.s.gather) {
+			cvmx_buf_ptr_t *p_ptr;
+			cvmx_buf_ptr_t blk;
+
+			p_ptr = cvmx_phys_to_ptr(
+				cvmx_pko3_legacy_paddr(node, packet.s.addr));
+			blk = p_ptr[0];
+			data_ptr = cvmx_phys_to_ptr(
+				cvmx_pko3_legacy_paddr(node, blk.s.addr));
+		} else {
+			data_ptr = cvmx_phys_to_ptr(
+				cvmx_pko3_legacy_paddr(node, packet.s.addr));
+		}
+
+		/* Get IP header offset */
+		ipoff = pko_command.s.ipoffp1 - 1;
+
+		/* Parse IP header, version, L4 protocol */
+		hdr_s->s.l3ptr = ipoff;
+		ip0 = data_ptr[ipoff];
+
+		/* IPv4 header length, checksum offload */
+		if ((ip0 >> 4) == 4) {
+			hdr_s->s.l4ptr = hdr_s->s.l3ptr + ((ip0 & 0xf) << 2);
+			l4_proto = data_ptr[ipoff + 9];
+			hdr_s->s.ckl3 = 1; /* Only valid for IPv4 */
+		}
+		/* IPv6 header length is fixed, no checksum */
+		if ((ip0 >> 4) == 6) {
+			hdr_s->s.l4ptr = hdr_s->s.l3ptr + 40;
+			l4_proto = data_ptr[ipoff + 6];
+		}
+		/* Set L4 checksum algo based on L4 protocol */
+		if (l4_proto == 6)
+			hdr_s->s.ckl4 = /* TCP */ 2;
+		else if (l4_proto == 17)
+			hdr_s->s.ckl4 = /* UDP */ 1;
+		else if (l4_proto == 132)
+			hdr_s->s.ckl4 = /* SCTP */ 3;
+		else
+			hdr_s->s.ckl4 = /* Unknown */ 0;
+	}
+
+	if (pko_command.s.gather) {
+		/* Process legacy gather list */
+		cvmx_pko_buf_ptr_t gather_s;
+		cvmx_buf_ptr_t *p_ptr;
+		cvmx_buf_ptr_t blk;
+		unsigned int i;
+
+		/* Get gather list pointer */
+		p_ptr = cvmx_phys_to_ptr(
+			cvmx_pko3_legacy_paddr(node, packet.s.addr));
+		blk = p_ptr[0];
+		/* setup data_ptr */
+		data_ptr = cvmx_phys_to_ptr(
+			cvmx_pko3_legacy_paddr(node, blk.s.addr));
+
+		for (i = 0; i < seg_cnt; i++) {
+			if (cvmx_unlikely(cvmx_pko3_legacy_pool(
+						  &desc, blk.s.pool) < 0))
+				return CVMX_PKO_NO_MEMORY;
+
+			/* Insert PKO_SEND_GATHER_S for the current buffer */
+			gather_s.u64 = 0;
+			gather_s.s.subdc3 = CVMX_PKO_SENDSUBDC_GATHER;
+			gather_s.s.size = blk.s.size;
+			gather_s.s.i = blk.s.i;
+			gather_s.s.addr =
+				cvmx_pko3_legacy_paddr(node, blk.s.addr);
+
+			res = __cvmx_pko3_cmd_subdc_add(&desc, gather_s.u64);
+			if (res < 0)
+				return CVMX_PKO_NO_MEMORY;
+
+			/* get next bufptr */
+			blk = p_ptr[i + 1];
+		} /* for i */
+
+		/* Free original gather-list buffer */
+		if ((pko_command.s.ignore_i && !pko_command.s.dontfree) ||
+		    packet.s.i == pko_command.s.dontfree)
+			cvmx_fpa_free_nosync(p_ptr, packet.s.pool,
+					     (i - 1) / 16 + 1);
+	} else {
+		/* Process legacy linked buffer list */
+		cvmx_pko_buf_ptr_t gather_s;
+		cvmx_buf_ptr_t blk;
+		void *vptr;
+
+		data_ptr = cvmx_phys_to_ptr(
+			cvmx_pko3_legacy_paddr(node, packet.s.addr));
+		blk = packet;
+
+		/*
+		 * Legacy linked-buffers converted into flat gather list
+		 * so that the AURA can optionally be changed to reflect
+		 * the POOL number in the legacy pointers
+		 */
+		do {
+			/* Insert PKO_SEND_AURA_S if pool changes */
+			if (cvmx_unlikely(cvmx_pko3_legacy_pool(
+						  &desc, blk.s.pool) < 0))
+				return CVMX_PKO_NO_MEMORY;
+
+			/* Insert PKO_SEND_GATHER_S for the current buffer */
+			gather_s.u64 = 0;
+			gather_s.s.subdc3 = CVMX_PKO_SENDSUBDC_GATHER;
+			gather_s.s.size = blk.s.size;
+			gather_s.s.i = blk.s.i;
+			gather_s.s.addr =
+				cvmx_pko3_legacy_paddr(node, blk.s.addr);
+
+			res = __cvmx_pko3_cmd_subdc_add(&desc, gather_s.u64);
+			if (res < 0)
+				return CVMX_PKO_NO_MEMORY;
+
+			/* Get the next buffer pointer */
+			vptr = cvmx_phys_to_ptr(
+				cvmx_pko3_legacy_paddr(node, blk.s.addr));
+			memcpy(&blk, vptr - sizeof(blk), sizeof(blk));
+
+			/* Decrement segment count */
+			seg_cnt--;
+
+		} while (seg_cnt > 0);
+	}
+
+	/* This field indicates the presence of 3rd legacy command word */
+	/* NOTE: legacy 3rd word may contain CN78XX native phys addr already */
+	if (cvmx_unlikely(pko_command.s.rsp)) {
+		/* PTP bit in word3 is not supported -
+		 * can not be distibguished from larger phys_addr[42..41]
+		 */
+		if (pko_command.s.wqp) {
+			/* <addr> is an SSO WQE */
+			cvmx_wqe_word1_t *wqe_p;
+			cvmx_pko_send_work_t work_s;
+
+			work_s.u64 = 0;
+			work_s.s.subdc4 = CVMX_PKO_SENDSUBDC_WORK;
+			work_s.s.addr = addr;
+			/* Assume WQE is legacy format too */
+			wqe_p = cvmx_phys_to_ptr(addr + sizeof(u64));
+			work_s.s.grp = wqe_p->cn38xx.grp;
+			work_s.s.tt = wqe_p->tag_type;
+
+			res = __cvmx_pko3_cmd_subdc_add(&desc, work_s.u64);
+		} else {
+			cvmx_pko_send_mem_t mem_s;
+			/* MEMALG_SET broken on Pass1 */
+			if (OCTEON_IS_MODEL(OCTEON_CN78XX_PASS1_0)) {
+				debug("%s: ERROR: PKO byte-clear not supported\n",
+				      __func__);
+			}
+			/* <addr> is a physical address of byte clear */
+			mem_s.u64 = 0;
+			mem_s.s.subdc4 = CVMX_PKO_SENDSUBDC_MEM;
+			mem_s.s.addr = addr;
+			mem_s.s.dsz = MEMDSZ_B8;
+			mem_s.s.alg = MEMALG_SET;
+			mem_s.s.offset = 0;
+
+			res = __cvmx_pko3_cmd_subdc_add(&desc, mem_s.u64);
+		}
+		if (res < 0)
+			return CVMX_PKO_NO_MEMORY;
+	}
+
+	/* FAU counter binding reg0 */
+	if (pko_command.s.reg0) {
+		cvmx_pko_send_mem_t mem_s;
+
+		debug("%s: Legacy FAU commands: reg0=%#x sz0=%#x\n", __func__,
+		      pko_command.s.reg0, pko_command.s.size0);
+		mem_s.u64 = 0;
+		mem_s.s.subdc4 = CVMX_PKO_SENDSUBDC_MEM;
+		mem_s.s.addr = cvmx_ptr_to_phys(
+			CASTPTR(void, __cvmx_fau_sw_addr(pko_command.s.reg0)));
+		if (cvmx_likely(pko_command.s.size0 == CVMX_FAU_OP_SIZE_64))
+			mem_s.s.dsz = MEMDSZ_B64;
+		else if (pko_command.s.size0 == CVMX_FAU_OP_SIZE_32)
+			mem_s.s.dsz = MEMDSZ_B32;
+		else if (pko_command.s.size0 == CVMX_FAU_OP_SIZE_16)
+			mem_s.s.dsz = MEMDSZ_B16;
+		else
+			mem_s.s.dsz = MEMDSZ_B8;
+
+		if (mem_s.s.dsz == MEMDSZ_B16 || mem_s.s.dsz == MEMDSZ_B8)
+			debug("%s: ERROR: 8/16 bit decrement unsupported",
+			      __func__);
+
+		mem_s.s.offset = pko_command.s.subone0;
+		if (mem_s.s.offset)
+			mem_s.s.alg = MEMALG_SUB;
+		else
+			mem_s.s.alg = MEMALG_SUBLEN;
+
+		res = __cvmx_pko3_cmd_subdc_add(&desc, mem_s.u64);
+		if (res < 0)
+			return CVMX_PKO_NO_MEMORY;
+	}
+
+	/* FAU counter binding reg1 */
+	if (cvmx_unlikely(pko_command.s.reg1)) {
+		cvmx_pko_send_mem_t mem_s;
+
+		debug("%s: Legacy FAU commands: reg1=%#x sz1=%#x\n", __func__,
+		      pko_command.s.reg1, pko_command.s.size1);
+		mem_s.u64 = 0;
+		mem_s.s.subdc4 = CVMX_PKO_SENDSUBDC_MEM;
+		mem_s.s.addr = cvmx_ptr_to_phys(
+			CASTPTR(void, __cvmx_fau_sw_addr(pko_command.s.reg1)));
+		if (cvmx_likely(pko_command.s.size1 == CVMX_FAU_OP_SIZE_64))
+			mem_s.s.dsz = MEMDSZ_B64;
+		else if (pko_command.s.size1 == CVMX_FAU_OP_SIZE_32)
+			mem_s.s.dsz = MEMDSZ_B32;
+		else if (pko_command.s.size1 == CVMX_FAU_OP_SIZE_16)
+			mem_s.s.dsz = MEMDSZ_B16;
+		else
+			mem_s.s.dsz = MEMDSZ_B8;
+
+		if (mem_s.s.dsz == MEMDSZ_B16 || mem_s.s.dsz == MEMDSZ_B8)
+			printf("%s: ERROR: 8/16 bit decrement unsupported",
+			       __func__);
+
+		mem_s.s.offset = pko_command.s.subone1;
+		if (mem_s.s.offset)
+			mem_s.s.alg = MEMALG_SUB;
+		else
+			mem_s.s.alg = MEMALG_SUBLEN;
+
+		res = __cvmx_pko3_cmd_subdc_add(&desc, mem_s.u64);
+		if (res < 0)
+			return CVMX_PKO_NO_MEMORY;
+	}
+
+	/* These PKO_HDR_S fields are not used: */
+	/* hdr_s->s.ds does not have legacy equivalent, remains 0 */
+	/* hdr_s->s.format has no legacy equivalent, remains 0 */
+
+	/*** Finalize command buffer ***/
+	res = __cvmx_pko3_cmd_done(&desc);
+	if (res < 0)
+		return CVMX_PKO_NO_MEMORY;
+
+	/*** Send the PKO3 command into the Descriptor Queue ***/
+	pko_status =
+		__cvmx_pko3_lmtdma(desc.port_node, dq, desc.word_count, tag_sw);
+
+	/*** Map PKO3 result codes to legacy return values ***/
+	if (cvmx_likely(pko_status.s.dqstatus == PKO_DQSTATUS_PASS))
+		return CVMX_PKO_SUCCESS;
+
+	debug("%s: ERROR: failed to enqueue: %s\n", __func__,
+	      pko_dqstatus_error(pko_status.s.dqstatus));
+
+	if (pko_status.s.dqstatus == PKO_DQSTATUS_ALREADY)
+		return CVMX_PKO_PORT_ALREADY_SETUP;
+	if (pko_status.s.dqstatus == PKO_DQSTATUS_NOFPABUF ||
+	    pko_status.s.dqstatus == PKO_DQSTATUS_NOPKOBUF)
+		return CVMX_PKO_NO_MEMORY;
+	if (pko_status.s.dqstatus == PKO_DQSTATUS_NOTCREATED)
+		return CVMX_PKO_INVALID_QUEUE;
+	if (pko_status.s.dqstatus == PKO_DQSTATUS_BADSTATE)
+		return CVMX_PKO_CMD_QUEUE_INIT_ERROR;
+	if (pko_status.s.dqstatus == PKO_DQSTATUS_SENDPKTDROP)
+		return CVMX_PKO_INVALID_PORT;
+
+	return CVMX_PKO_INVALID_PORT;
+}
Signature · 1 line
2.35.1
#34 lore raw

PATCH 38/52 mips: octeon: Add cvmx-pko3-resources.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-pko3-resources.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 arch/mips/mach-octeon/cvmx-pko3-resources.c | 229 ++++++++++++++++++++
 1 file changed, 229 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-resources.c
arch/mips/mach-octeon/cvmx-pko3-resources.c new file +229 -0
new file mode 100644
index 000000000000..3d17d84832cf
@@ -0,0 +1,229 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ *
+ * PKO resources.
+ */
+
+#include <errno.h>
+#include <log.h>
+#include <time.h>
+#include <linux/delay.h>
+
+#include <mach/cvmx-regs.h>
+#include <mach/cvmx-csr.h>
+#include <mach/cvmx-bootmem.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+#include <mach/cvmx-pcie.h>
+#include <mach/cvmx-coremask.h>
+#include <mach/cvmx-range.h>
+#include <mach/cvmx-global-resources.h>
+
+#include <mach/cvmx-agl-defs.h>
+#include <mach/cvmx-bgxx-defs.h>
+#include <mach/cvmx-ciu-defs.h>
+#include <mach/cvmx-gmxx-defs.h>
+#include <mach/cvmx-gserx-defs.h>
+#include <mach/cvmx-ilk-defs.h>
+#include <mach/cvmx-ipd-defs.h>
+#include <mach/cvmx-pcsx-defs.h>
+#include <mach/cvmx-pcsxx-defs.h>
+#include <mach/cvmx-pki-defs.h>
+#include <mach/cvmx-pko-defs.h>
+#include <mach/cvmx-xcv-defs.h>
+
+#include <mach/cvmx-hwpko.h>
+#include <mach/cvmx-ilk.h>
+#include <mach/cvmx-pki.h>
+#include <mach/cvmx-pko3.h>
+#include <mach/cvmx-pko3-queue.h>
+#include <mach/cvmx-pko3-resources.h>
+
+#include <mach/cvmx-helper.h>
+#include <mach/cvmx-helper-board.h>
+#include <mach/cvmx-helper-cfg.h>
+
+#include <mach/cvmx-helper-bgx.h>
+#include <mach/cvmx-helper-cfg.h>
+#include <mach/cvmx-helper-util.h>
+#include <mach/cvmx-helper-pki.h>
+
+#define CVMX_GR_TAG_PKO_PORT_QUEUES(x)                                         \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'p', 'o', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_L2_QUEUES(x)                                           \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'l', '2', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_L3_QUEUES(x)                                           \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'l', '3', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_L4_QUEUES(x)                                           \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'l', '4', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_L5_QUEUES(x)                                           \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'l', '5', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_DESCR_QUEUES(x)                                        \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'd', 'e', 'q', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+#define CVMX_GR_TAG_PKO_PORT_INDEX(x)                                          \
+	cvmx_get_gr_tag('c', 'v', 'm', '_', 'p', 'k', 'o', 'p', 'i', 'd', '_', \
+			((x) + '0'), '.', '.', '.', '.')
+
+/*
+ * @INRWENAL
+ * Per-DQ parameters, current and maximum queue depth counters
+ */
+cvmx_pko3_dq_params_t *__cvmx_pko3_dq_params[CVMX_MAX_NODES];
+
+static const short cvmx_pko_num_queues_78XX[256] = {
+	[CVMX_PKO_PORT_QUEUES] = 32, [CVMX_PKO_L2_QUEUES] = 512,
+	[CVMX_PKO_L3_QUEUES] = 512,  [CVMX_PKO_L4_QUEUES] = 1024,
+	[CVMX_PKO_L5_QUEUES] = 1024, [CVMX_PKO_DESCR_QUEUES] = 1024
+};
+
+static const short cvmx_pko_num_queues_73XX[256] = {
+	[CVMX_PKO_PORT_QUEUES] = 16, [CVMX_PKO_L2_QUEUES] = 256,
+	[CVMX_PKO_L3_QUEUES] = 256,  [CVMX_PKO_L4_QUEUES] = 0,
+	[CVMX_PKO_L5_QUEUES] = 0,    [CVMX_PKO_DESCR_QUEUES] = 256
+};
+
+int cvmx_pko3_num_level_queues(enum cvmx_pko3_level_e level)
+{
+	unsigned int nq = 0, ne = 0;
+
+	if (OCTEON_IS_MODEL(OCTEON_CN78XX)) {
+		ne = NUM_ELEMENTS(cvmx_pko_num_queues_78XX);
+		nq = cvmx_pko_num_queues_78XX[level];
+	}
+	if (OCTEON_IS_MODEL(OCTEON_CN73XX) || OCTEON_IS_MODEL(OCTEON_CNF75XX)) {
+		ne = NUM_ELEMENTS(cvmx_pko_num_queues_73XX);
+		nq = cvmx_pko_num_queues_73XX[level];
+	}
+
+	if (nq == 0 || level >= ne) {
+		printf("ERROR: %s: queue level %#x invalid\n", __func__, level);
+		return -1;
+	}
+
+	return nq;
+}
+
+static inline struct global_resource_tag
+__cvmx_pko_get_queues_resource_tag(int node, enum cvmx_pko3_level_e queue_level)
+{
+	if (cvmx_pko3_num_level_queues(queue_level) == 0) {
+		printf("ERROR: %s: queue level %#x invalid\n", __func__,
+		       queue_level);
+		return CVMX_GR_TAG_INVALID;
+	}
+
+	switch (queue_level) {
+	case CVMX_PKO_PORT_QUEUES:
+		return CVMX_GR_TAG_PKO_PORT_QUEUES(node);
+	case CVMX_PKO_L2_QUEUES:
+		return CVMX_GR_TAG_PKO_L2_QUEUES(node);
+	case CVMX_PKO_L3_QUEUES:
+		return CVMX_GR_TAG_PKO_L3_QUEUES(node);
+	case CVMX_PKO_L4_QUEUES:
+		return CVMX_GR_TAG_PKO_L4_QUEUES(node);
+	case CVMX_PKO_L5_QUEUES:
+		return CVMX_GR_TAG_PKO_L5_QUEUES(node);
+	case CVMX_PKO_DESCR_QUEUES:
+		return CVMX_GR_TAG_PKO_DESCR_QUEUES(node);
+	default:
+		printf("ERROR: %s: queue level %#x invalid\n", __func__,
+		       queue_level);
+		return CVMX_GR_TAG_INVALID;
+	}
+}
+
+/**
+ * Allocate or reserve a pko resource - called by wrapper functions
+ * @param tag processed global resource tag
+ * @param base_queue if specified the queue to reserve
+ * @param owner to be specified for resource
+ * @param num_queues to allocate
+ * @param max_num_queues for global resource
+ */
+int cvmx_pko_alloc_global_resource(struct global_resource_tag tag,
+				   int base_queue, int owner, int num_queues,
+				   int max_num_queues)
+{
+	int res;
+
+	if (cvmx_create_global_resource_range(tag, max_num_queues)) {
+		debug("ERROR: Failed to create PKO3 resource: %lx-%lx\n",
+		      (unsigned long)tag.hi, (unsigned long)tag.lo);
+		return -1;
+	}
+	if (base_queue >= 0) {
+		res = cvmx_reserve_global_resource_range(tag, owner, base_queue,
+							 num_queues);
+	} else {
+		res = cvmx_allocate_global_resource_range(tag, owner,
+							  num_queues, 1);
+	}
+	if (res < 0) {
+		debug("ERROR: Failed to %s PKO3 tag %lx:%lx, %i %i %i %i.\n",
+		      ((base_queue < 0) ? "allocate" : "reserve"),
+		      (unsigned long)tag.hi, (unsigned long)tag.lo, base_queue,
+		      owner, num_queues, max_num_queues);
+		return -1;
+	}
+
+	return res;
+}
+
+/**
+ * Allocate or reserve PKO queues - wrapper for cvmx_pko_alloc_global_resource
+ *
+ * @param node on which to allocate/reserve PKO queues
+ * @param level of PKO queue
+ * @param owner of reserved/allocated resources
+ * @param base_queue to start reservation/allocatation
+ * @param num_queues number of queues to be allocated
+ * @return 0 on success, -1 on failure
+ */
+int cvmx_pko_alloc_queues(int node, int level, int owner, int base_queue,
+			  int num_queues)
+{
+	struct global_resource_tag tag =
+		__cvmx_pko_get_queues_resource_tag(node, level);
+	int max_num_queues = cvmx_pko3_num_level_queues(level);
+
+	return cvmx_pko_alloc_global_resource(tag, base_queue, owner,
+					      num_queues, max_num_queues);
+}
+
+/**
+ * Free an allocated/reserved PKO queues for a certain level and owner
+ *
+ * @param node on which to allocate/reserve PKO queues
+ * @param level of PKO queue
+ * @param owner of reserved/allocated resources
+ * @return 0 on success, -1 on failure
+ */
+int cvmx_pko_free_queues(int node, int level, int owner)
+{
+	struct global_resource_tag tag =
+		__cvmx_pko_get_queues_resource_tag(node, level);
+
+	return cvmx_free_global_resource_range_with_owner(tag, owner);
+}
+
+/**
+ * @INTERNAL
+ *
+ * Initialize the pointer to the descriptor queue parameter table.
+ * The table is one named block per node, and may be shared between
+ * applications.
+ */
+int __cvmx_pko3_dq_param_setup(unsigned int node)
+{
+	return 0;
+}
Signature · 1 line
2.35.1
#35 lore raw

PATCH 39/52 mips: octeon: Add cvmx-pko-internal-ports-range.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-pko-internal-ports-range.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 .../cvmx-pko-internal-ports-range.c           | 164 ++++++++++++++++++
 1 file changed, 164 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c
arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c new file +164 -0
new file mode 100644
index 000000000000..259453eacd5c
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ */
+
+#include <errno.h>
+#include <log.h>
+#include <time.h>
+#include <linux/delay.h>
+
+#include <mach/cvmx-regs.h>
+#include <mach/cvmx-csr.h>
+#include <mach/cvmx-bootmem.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+#include <mach/cvmx-pcie.h>
+#include <mach/cvmx-coremask.h>
+#include <mach/cvmx-range.h>
+#include <mach/cvmx-global-resources.h>
+
+#include <mach/cvmx-agl-defs.h>
+#include <mach/cvmx-bgxx-defs.h>
+#include <mach/cvmx-ciu-defs.h>
+#include <mach/cvmx-gmxx-defs.h>
+#include <mach/cvmx-gserx-defs.h>
+#include <mach/cvmx-ilk-defs.h>
+#include <mach/cvmx-ipd-defs.h>
+#include <mach/cvmx-pcsx-defs.h>
+#include <mach/cvmx-pcsxx-defs.h>
+#include <mach/cvmx-pki-defs.h>
+#include <mach/cvmx-pko-defs.h>
+#include <mach/cvmx-xcv-defs.h>
+
+#include <mach/cvmx-hwpko.h>
+#include <mach/cvmx-ilk.h>
+#include <mach/cvmx-ipd.h>
+#include <mach/cvmx-pki.h>
+#include <mach/cvmx-pko3.h>
+#include <mach/cvmx-pko3-queue.h>
+#include <mach/cvmx-pko3-resources.h>
+
+#include <mach/cvmx-helper.h>
+#include <mach/cvmx-helper-board.h>
+#include <mach/cvmx-helper-cfg.h>
+
+#include <mach/cvmx-helper-bgx.h>
+#include <mach/cvmx-helper-cfg.h>
+#include <mach/cvmx-helper-util.h>
+#include <mach/cvmx-helper-pki.h>
+
+union interface_port {
+	struct {
+		int port;
+		int interface;
+	} s;
+	u64 u64;
+};
+
+static int dbg;
+
+static int port_range_init;
+
+int __cvmx_pko_internal_ports_range_init(void)
+{
+	int rv = 0;
+
+	if (port_range_init)
+		return 0;
+	port_range_init = 1;
+	rv = cvmx_create_global_resource_range(CVMX_GR_TAG_PKO_IPORTS,
+					       CVMX_HELPER_CFG_MAX_PKO_QUEUES);
+	if (rv != 0)
+		debug("ERROR : Failed to initialize pko internal port range\n");
+	return rv;
+}
+
+int cvmx_pko_internal_ports_alloc(int xiface, int port, u64 count)
+{
+	int ret_val = -1;
+	union interface_port inf_port;
+	struct cvmx_xiface xi = cvmx_helper_xiface_to_node_interface(xiface);
+
+	__cvmx_pko_internal_ports_range_init();
+	inf_port.s.interface = xi.interface;
+	inf_port.s.port = port;
+	ret_val = cvmx_allocate_global_resource_range(CVMX_GR_TAG_PKO_IPORTS,
+						      inf_port.u64, count, 1);
+	if (dbg)
+		debug("internal port alloc : port=%02d base=%02d count=%02d\n",
+		      (int)port, ret_val, (int)count);
+	if (ret_val == -1)
+		return ret_val;
+	cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base = ret_val;
+	cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports = count;
+	return 0;
+}
+
+/*
+ * Return the internal ports base
+ *
+ * @param  port   the port for which the queues are returned
+ *
+ * @return  0 on success
+ *         -1 on failure
+ */
+int cvmx_pko_internal_ports_free(int xiface, int port)
+{
+	struct cvmx_xiface xi = cvmx_helper_xiface_to_node_interface(xiface);
+	int ret_val = -1;
+
+	__cvmx_pko_internal_ports_range_init();
+	ret_val = cvmx_free_global_resource_range_with_base(
+		CVMX_GR_TAG_PKO_IPORTS,
+		cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base,
+		cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports);
+	if (ret_val != 0)
+		return ret_val;
+	cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_port_base =
+		CVMX_HELPER_CFG_INVALID_VALUE;
+	cvmx_cfg_port[xi.node][xi.interface][port].ccpp_pko_num_ports =
+		CVMX_HELPER_CFG_INVALID_VALUE;
+
+	return 0;
+}
+
+void cvmx_pko_internal_ports_range_free_all(void)
+{
+	int interface, port;
+
+	__cvmx_pko_internal_ports_range_init();
+	for (interface = 0; interface < CVMX_HELPER_MAX_IFACE; interface++)
+		for (port = 0; port < CVMX_HELPER_CFG_MAX_PORT_PER_IFACE;
+		     port++) {
+			if (cvmx_cfg_port[0][interface][port]
+				    .ccpp_pko_port_base !=
+			    CVMX_HELPER_CFG_INVALID_VALUE)
+				cvmx_pko_internal_ports_free(interface, port);
+		}
+	//cvmx_range_show(pko_internal_ports_range);
+}
+
+void cvmx_pko_internal_ports_range_show(void)
+{
+	int interface, port;
+
+	__cvmx_pko_internal_ports_range_init();
+	cvmx_show_global_resource_range(CVMX_GR_TAG_PKO_IPORTS);
+	for (interface = 0; interface < CVMX_HELPER_MAX_IFACE; interface++)
+		for (port = 0; port < CVMX_HELPER_CFG_MAX_PORT_PER_IFACE;
+		     port++) {
+			if (cvmx_cfg_port[0][interface][port]
+				    .ccpp_pko_port_base !=
+			    CVMX_HELPER_CFG_INVALID_VALUE)
+				debug("interface=%d port=%d port_base=%d port_cnt=%d\n",
+				      interface, port,
+				      (int)cvmx_cfg_port[0][interface][port]
+					      .ccpp_pko_port_base,
+				      (int)cvmx_cfg_port[0][interface][port]
+					      .ccpp_pko_num_ports);
+		}
+}
Signature · 1 line
2.35.1
#36 lore raw

PATCH 40/52 mips: octeon: Add cvmx-qlm-tables.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-qlm-tables.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 arch/mips/mach-octeon/cvmx-qlm-tables.c | 292 ++++++++++++++++++++++++
 1 file changed, 292 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-qlm-tables.c
arch/mips/mach-octeon/cvmx-qlm-tables.c new file +292 -0
new file mode 100644
index 000000000000..ca2289225d37
@@ -0,0 +1,292 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ */
+
+#include <mach/cvmx-regs.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+
+const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn63xx[] = {
+	{ "prbs_err_cnt", 299, 252 },	   // prbs_err_cnt[47..0]
+	{ "prbs_lock", 251, 251 },	   // prbs_lock
+	{ "jtg_prbs_rst_n", 250, 250 },	   // jtg_prbs_rst_n
+	{ "jtg_run_prbs31", 249, 249 },	   // jtg_run_prbs31
+	{ "jtg_run_prbs7", 248, 248 },	   // jtg_run_prbs7
+	{ "Unused1", 247, 245 },	   // 0
+	{ "cfg_pwrup_set", 244, 244 },	   // cfg_pwrup_set
+	{ "cfg_pwrup_clr", 243, 243 },	   // cfg_pwrup_clr
+	{ "cfg_rst_n_set", 242, 242 },	   // cfg_rst_n_set
+	{ "cfg_rst_n_clr", 241, 241 },	   // cfg_rst_n_clr
+	{ "cfg_tx_idle_set", 240, 240 },   // cfg_tx_idle_set
+	{ "cfg_tx_idle_clr", 239, 239 },   // cfg_tx_idle_clr
+	{ "cfg_tx_byp", 238, 238 },	   // cfg_tx_byp
+	{ "cfg_tx_byp_inv", 237, 237 },	   // cfg_tx_byp_inv
+	{ "cfg_tx_byp_val", 236, 227 },	   // cfg_tx_byp_val[9..0]
+	{ "cfg_loopback", 226, 226 },	   // cfg_loopback
+	{ "shlpbck", 225, 224 },	   // shlpbck[1..0]
+	{ "sl_enable", 223, 223 },	   // sl_enable
+	{ "sl_posedge_sample", 222, 222 }, // sl_posedge_sample
+	{ "trimen", 221, 220 },		   // trimen[1..0]
+	{ "serdes_tx_byp", 219, 219 },	   // serdes_tx_byp
+	{ "serdes_pll_byp", 218, 218 },	   // serdes_pll_byp
+	{ "lowf_byp", 217, 217 },	   // lowf_byp
+	{ "spdsel_byp", 216, 216 },	   // spdsel_byp
+	{ "div4_byp", 215, 215 },	   // div4_byp
+	{ "clkf_byp", 214, 208 },	   // clkf_byp[6..0]
+	{ "Unused2", 207, 206 },	   // 0
+	{ "biasdrv_hs_ls_byp", 205, 201 }, // biasdrv_hs_ls_byp[4..0]
+	{ "tcoeff_hf_ls_byp", 200, 197 },  // tcoeff_hf_ls_byp[3..0]
+	{ "biasdrv_hf_byp", 196, 192 },	   // biasdrv_hf_byp[4..0]
+	{ "tcoeff_hf_byp", 191, 188 },	   // tcoeff_hf_byp[3..0]
+	{ "Unused3", 187, 186 },	   // 0
+	{ "biasdrv_lf_ls_byp", 185, 181 }, // biasdrv_lf_ls_byp[4..0]
+	{ "tcoeff_lf_ls_byp", 180, 177 },  // tcoeff_lf_ls_byp[3..0]
+	{ "biasdrv_lf_byp", 176, 172 },	   // biasdrv_lf_byp[4..0]
+	{ "tcoeff_lf_byp", 171, 168 },	   // tcoeff_lf_byp[3..0]
+	{ "Unused4", 167, 167 },	   // 0
+	{ "interpbw", 166, 162 },	   // interpbw[4..0]
+	{ "pll_cpb", 161, 159 },	   // pll_cpb[2..0]
+	{ "pll_cps", 158, 156 },	   // pll_cps[2..0]
+	{ "pll_diffamp", 155, 152 },	   // pll_diffamp[3..0]
+	{ "Unused5", 151, 150 },	   // 0
+	{ "cfg_rx_idle_set", 149, 149 },   // cfg_rx_idle_set
+	{ "cfg_rx_idle_clr", 148, 148 },   // cfg_rx_idle_clr
+	{ "cfg_rx_idle_thr", 147, 144 },   // cfg_rx_idle_thr[3..0]
+	{ "cfg_com_thr", 143, 140 },	   // cfg_com_thr[3..0]
+	{ "cfg_rx_offset", 139, 136 },	   // cfg_rx_offset[3..0]
+	{ "cfg_skp_max", 135, 132 },	   // cfg_skp_max[3..0]
+	{ "cfg_skp_min", 131, 128 },	   // cfg_skp_min[3..0]
+	{ "cfg_fast_pwrup", 127, 127 },	   // cfg_fast_pwrup
+	{ "Unused6", 126, 100 },	   // 0
+	{ "detected_n", 99, 99 },	   // detected_n
+	{ "detected_p", 98, 98 },	   // detected_p
+	{ "dbg_res_rx", 97, 94 },	   // dbg_res_rx[3..0]
+	{ "dbg_res_tx", 93, 90 },	   // dbg_res_tx[3..0]
+	{ "cfg_tx_pol_set", 89, 89 },	   // cfg_tx_pol_set
+	{ "cfg_tx_pol_clr", 88, 88 },	   // cfg_tx_pol_clr
+	{ "cfg_rx_pol_set", 87, 87 },	   // cfg_rx_pol_set
+	{ "cfg_rx_pol_clr", 86, 86 },	   // cfg_rx_pol_clr
+	{ "cfg_rxd_set", 85, 85 },	   // cfg_rxd_set
+	{ "cfg_rxd_clr", 84, 84 },	   // cfg_rxd_clr
+	{ "cfg_rxd_wait", 83, 80 },	   // cfg_rxd_wait[3..0]
+	{ "cfg_cdr_limit", 79, 79 },	   // cfg_cdr_limit
+	{ "cfg_cdr_rotate", 78, 78 },	   // cfg_cdr_rotate
+	{ "cfg_cdr_bw_ctl", 77, 76 },	   // cfg_cdr_bw_ctl[1..0]
+	{ "cfg_cdr_trunc", 75, 74 },	   // cfg_cdr_trunc[1..0]
+	{ "cfg_cdr_rqoffs", 73, 64 },	   // cfg_cdr_rqoffs[9..0]
+	{ "cfg_cdr_inc2", 63, 58 },	   // cfg_cdr_inc2[5..0]
+	{ "cfg_cdr_inc1", 57, 52 },	   // cfg_cdr_inc1[5..0]
+	{ "fusopt_voter_sync", 51, 51 },   // fusopt_voter_sync
+	{ "rndt", 50, 50 },		   // rndt
+	{ "hcya", 49, 49 },		   // hcya
+	{ "hyst", 48, 48 },		   // hyst
+	{ "idle_dac", 47, 45 },		   // idle_dac[2..0]
+	{ "bg_ref_sel", 44, 44 },	   // bg_ref_sel
+	{ "ic50dac", 43, 39 },		   // ic50dac[4..0]
+	{ "ir50dac", 38, 34 },		   // ir50dac[4..0]
+	{ "tx_rout_comp_bypass", 33, 33 }, // tx_rout_comp_bypass
+	{ "tx_rout_comp_value", 32, 29 },  // tx_rout_comp_value[3..0]
+	{ "tx_res_offset", 28, 25 },	   // tx_res_offset[3..0]
+	{ "rx_rout_comp_bypass", 24, 24 }, // rx_rout_comp_bypass
+	{ "rx_rout_comp_value", 23, 20 },  // rx_rout_comp_value[3..0]
+	{ "rx_res_offset", 19, 16 },	   // rx_res_offset[3..0]
+	{ "rx_cap_gen2", 15, 12 },	   // rx_cap_gen2[3..0]
+	{ "rx_eq_gen2", 11, 8 },	   // rx_eq_gen2[3..0]
+	{ "rx_cap_gen1", 7, 4 },	   // rx_cap_gen1[3..0]
+	{ "rx_eq_gen1", 3, 0 },		   // rx_eq_gen1[3..0]
+	{ NULL, -1, -1 }
+};
+
+const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn66xx[] = {
+	{ "prbs_err_cnt", 303, 256 },	   // prbs_err_cnt[47..0]
+	{ "prbs_lock", 255, 255 },	   // prbs_lock
+	{ "jtg_prbs_rx_rst_n", 254, 254 }, // jtg_prbs_rx_rst_n
+	{ "jtg_prbs_tx_rst_n", 253, 253 }, // jtg_prbs_tx_rst_n
+	{ "jtg_prbs_mode", 252, 251 },	   // jtg_prbs_mode[252:251]
+	{ "jtg_prbs_rst_n", 250, 250 },	   // jtg_prbs_rst_n
+	{ "jtg_run_prbs31", 249,
+	  249 }, // jtg_run_prbs31 - Use jtg_prbs_mode instead
+	{ "jtg_run_prbs7", 248,
+	  248 },		  // jtg_run_prbs7 - Use jtg_prbs_mode instead
+	{ "Unused1", 247, 246 },  // 0
+	{ "div5_byp", 245, 245 }, // div5_byp
+	{ "cfg_pwrup_set", 244, 244 },	   // cfg_pwrup_set
+	{ "cfg_pwrup_clr", 243, 243 },	   // cfg_pwrup_clr
+	{ "cfg_rst_n_set", 242, 242 },	   // cfg_rst_n_set
+	{ "cfg_rst_n_clr", 241, 241 },	   // cfg_rst_n_clr
+	{ "cfg_tx_idle_set", 240, 240 },   // cfg_tx_idle_set
+	{ "cfg_tx_idle_clr", 239, 239 },   // cfg_tx_idle_clr
+	{ "cfg_tx_byp", 238, 238 },	   // cfg_tx_byp
+	{ "cfg_tx_byp_inv", 237, 237 },	   // cfg_tx_byp_inv
+	{ "cfg_tx_byp_val", 236, 227 },	   // cfg_tx_byp_val[9..0]
+	{ "cfg_loopback", 226, 226 },	   // cfg_loopback
+	{ "shlpbck", 225, 224 },	   // shlpbck[1..0]
+	{ "sl_enable", 223, 223 },	   // sl_enable
+	{ "sl_posedge_sample", 222, 222 }, // sl_posedge_sample
+	{ "trimen", 221, 220 },		   // trimen[1..0]
+	{ "serdes_tx_byp", 219, 219 },	   // serdes_tx_byp
+	{ "serdes_pll_byp", 218, 218 },	   // serdes_pll_byp
+	{ "lowf_byp", 217, 217 },	   // lowf_byp
+	{ "spdsel_byp", 216, 216 },	   // spdsel_byp
+	{ "div4_byp", 215, 215 },	   // div4_byp
+	{ "clkf_byp", 214, 208 },	   // clkf_byp[6..0]
+	{ "biasdrv_hs_ls_byp", 207, 203 }, // biasdrv_hs_ls_byp[4..0]
+	{ "tcoeff_hf_ls_byp", 202, 198 },  // tcoeff_hf_ls_byp[4..0]
+	{ "biasdrv_hf_byp", 197, 193 },	   // biasdrv_hf_byp[4..0]
+	{ "tcoeff_hf_byp", 192, 188 },	   // tcoeff_hf_byp[4..0]
+	{ "biasdrv_lf_ls_byp", 187, 183 }, // biasdrv_lf_ls_byp[4..0]
+	{ "tcoeff_lf_ls_byp", 182, 178 },  // tcoeff_lf_ls_byp[4..0]
+	{ "biasdrv_lf_byp", 177, 173 },	   // biasdrv_lf_byp[4..0]
+	{ "tcoeff_lf_byp", 172, 168 },	   // tcoeff_lf_byp[4..0]
+	{ "Unused4", 167, 167 },	   // 0
+	{ "interpbw", 166, 162 },	   // interpbw[4..0]
+	{ "pll_cpb", 161, 159 },	   // pll_cpb[2..0]
+	{ "pll_cps", 158, 156 },	   // pll_cps[2..0]
+	{ "pll_diffamp", 155, 152 },	   // pll_diffamp[3..0]
+	{ "cfg_err_thr", 151, 150 },	   // cfg_err_thr
+	{ "cfg_rx_idle_set", 149, 149 },   // cfg_rx_idle_set
+	{ "cfg_rx_idle_clr", 148, 148 },   // cfg_rx_idle_clr
+	{ "cfg_rx_idle_thr", 147, 144 },   // cfg_rx_idle_thr[3..0]
+	{ "cfg_com_thr", 143, 140 },	   // cfg_com_thr[3..0]
+	{ "cfg_rx_offset", 139, 136 },	   // cfg_rx_offset[3..0]
+	{ "cfg_skp_max", 135, 132 },	   // cfg_skp_max[3..0]
+	{ "cfg_skp_min", 131, 128 },	   // cfg_skp_min[3..0]
+	{ "cfg_fast_pwrup", 127, 127 },	   // cfg_fast_pwrup
+	{ "Unused6", 126, 101 },	   // 0
+	{ "cfg_indep_dis", 100, 100 },	   // cfg_indep_dis
+	{ "detected_n", 99, 99 },	   // detected_n
+	{ "detected_p", 98, 98 },	   // detected_p
+	{ "dbg_res_rx", 97, 94 },	   // dbg_res_rx[3..0]
+	{ "dbg_res_tx", 93, 90 },	   // dbg_res_tx[3..0]
+	{ "cfg_tx_pol_set", 89, 89 },	   // cfg_tx_pol_set
+	{ "cfg_tx_pol_clr", 88, 88 },	   // cfg_tx_pol_clr
+	{ "cfg_rx_pol_set", 87, 87 },	   // cfg_rx_pol_set
+	{ "cfg_rx_pol_clr", 86, 86 },	   // cfg_rx_pol_clr
+	{ "cfg_rxd_set", 85, 85 },	   // cfg_rxd_set
+	{ "cfg_rxd_clr", 84, 84 },	   // cfg_rxd_clr
+	{ "cfg_rxd_wait", 83, 80 },	   // cfg_rxd_wait[3..0]
+	{ "cfg_cdr_limit", 79, 79 },	   // cfg_cdr_limit
+	{ "cfg_cdr_rotate", 78, 78 },	   // cfg_cdr_rotate
+	{ "cfg_cdr_bw_ctl", 77, 76 },	   // cfg_cdr_bw_ctl[1..0]
+	{ "cfg_cdr_trunc", 75, 74 },	   // cfg_cdr_trunc[1..0]
+	{ "cfg_cdr_rqoffs", 73, 64 },	   // cfg_cdr_rqoffs[9..0]
+	{ "cfg_cdr_inc2", 63, 58 },	   // cfg_cdr_inc2[5..0]
+	{ "cfg_cdr_inc1", 57, 52 },	   // cfg_cdr_inc1[5..0]
+	{ "fusopt_voter_sync", 51, 51 },   // fusopt_voter_sync
+	{ "rndt", 50, 50 },		   // rndt
+	{ "hcya", 49, 49 },		   // hcya
+	{ "hyst", 48, 48 },		   // hyst
+	{ "idle_dac", 47, 45 },		   // idle_dac[2..0]
+	{ "bg_ref_sel", 44, 44 },	   // bg_ref_sel
+	{ "ic50dac", 43, 39 },		   // ic50dac[4..0]
+	{ "ir50dac", 38, 34 },		   // ir50dac[4..0]
+	{ "tx_rout_comp_bypass", 33, 33 }, // tx_rout_comp_bypass
+	{ "tx_rout_comp_value", 32, 29 },  // tx_rout_comp_value[3..0]
+	{ "tx_res_offset", 28, 25 },	   // tx_res_offset[3..0]
+	{ "rx_rout_comp_bypass", 24, 24 }, // rx_rout_comp_bypass
+	{ "rx_rout_comp_value", 23, 20 },  // rx_rout_comp_value[3..0]
+	{ "rx_res_offset", 19, 16 },	   // rx_res_offset[3..0]
+	{ "rx_cap_gen2", 15, 12 },	   // rx_cap_gen2[3..0]
+	{ "rx_eq_gen2", 11, 8 },	   // rx_eq_gen2[3..0]
+	{ "rx_cap_gen1", 7, 4 },	   // rx_cap_gen1[3..0]
+	{ "rx_eq_gen1", 3, 0 },		   // rx_eq_gen1[3..0]
+	{ NULL, -1, -1 }
+};
+
+const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn68xx[] = {
+	{ "prbs_err_cnt", 303, 256 },	   // prbs_err_cnt[47..0]
+	{ "prbs_lock", 255, 255 },	   // prbs_lock
+	{ "jtg_prbs_rx_rst_n", 254, 254 }, // jtg_prbs_rx_rst_n
+	{ "jtg_prbs_tx_rst_n", 253, 253 }, // jtg_prbs_tx_rst_n
+	{ "jtg_prbs_mode", 252, 251 },	   // jtg_prbs_mode[252:251]
+	{ "jtg_prbs_rst_n", 250, 250 },	   // jtg_prbs_rst_n
+	{ "jtg_run_prbs31", 249,
+	  249 }, // jtg_run_prbs31 - Use jtg_prbs_mode instead
+	{ "jtg_run_prbs7", 248,
+	  248 },		 // jtg_run_prbs7 - Use jtg_prbs_mode instead
+	{ "Unused1", 247, 245 }, // 0
+	{ "cfg_pwrup_set", 244, 244 },	   // cfg_pwrup_set
+	{ "cfg_pwrup_clr", 243, 243 },	   // cfg_pwrup_clr
+	{ "cfg_rst_n_set", 242, 242 },	   // cfg_rst_n_set
+	{ "cfg_rst_n_clr", 241, 241 },	   // cfg_rst_n_clr
+	{ "cfg_tx_idle_set", 240, 240 },   // cfg_tx_idle_set
+	{ "cfg_tx_idle_clr", 239, 239 },   // cfg_tx_idle_clr
+	{ "cfg_tx_byp", 238, 238 },	   // cfg_tx_byp
+	{ "cfg_tx_byp_inv", 237, 237 },	   // cfg_tx_byp_inv
+	{ "cfg_tx_byp_val", 236, 227 },	   // cfg_tx_byp_val[9..0]
+	{ "cfg_loopback", 226, 226 },	   // cfg_loopback
+	{ "shlpbck", 225, 224 },	   // shlpbck[1..0]
+	{ "sl_enable", 223, 223 },	   // sl_enable
+	{ "sl_posedge_sample", 222, 222 }, // sl_posedge_sample
+	{ "trimen", 221, 220 },		   // trimen[1..0]
+	{ "serdes_tx_byp", 219, 219 },	   // serdes_tx_byp
+	{ "serdes_pll_byp", 218, 218 },	   // serdes_pll_byp
+	{ "lowf_byp", 217, 217 },	   // lowf_byp
+	{ "spdsel_byp", 216, 216 },	   // spdsel_byp
+	{ "div4_byp", 215, 215 },	   // div4_byp
+	{ "clkf_byp", 214, 208 },	   // clkf_byp[6..0]
+	{ "biasdrv_hs_ls_byp", 207, 203 }, // biasdrv_hs_ls_byp[4..0]
+	{ "tcoeff_hf_ls_byp", 202, 198 },  // tcoeff_hf_ls_byp[4..0]
+	{ "biasdrv_hf_byp", 197, 193 },	   // biasdrv_hf_byp[4..0]
+	{ "tcoeff_hf_byp", 192, 188 },	   // tcoeff_hf_byp[4..0]
+	{ "biasdrv_lf_ls_byp", 187, 183 }, // biasdrv_lf_ls_byp[4..0]
+	{ "tcoeff_lf_ls_byp", 182, 178 },  // tcoeff_lf_ls_byp[4..0]
+	{ "biasdrv_lf_byp", 177, 173 },	   // biasdrv_lf_byp[4..0]
+	{ "tcoeff_lf_byp", 172, 168 },	   // tcoeff_lf_byp[4..0]
+	{ "Unused4", 167, 167 },	   // 0
+	{ "interpbw", 166, 162 },	   // interpbw[4..0]
+	{ "pll_cpb", 161, 159 },	   // pll_cpb[2..0]
+	{ "pll_cps", 158, 156 },	   // pll_cps[2..0]
+	{ "pll_diffamp", 155, 152 },	   // pll_diffamp[3..0]
+	{ "cfg_err_thr", 151, 150 },	   // cfg_err_thr
+	{ "cfg_rx_idle_set", 149, 149 },   // cfg_rx_idle_set
+	{ "cfg_rx_idle_clr", 148, 148 },   // cfg_rx_idle_clr
+	{ "cfg_rx_idle_thr", 147, 144 },   // cfg_rx_idle_thr[3..0]
+	{ "cfg_com_thr", 143, 140 },	   // cfg_com_thr[3..0]
+	{ "cfg_rx_offset", 139, 136 },	   // cfg_rx_offset[3..0]
+	{ "cfg_skp_max", 135, 132 },	   // cfg_skp_max[3..0]
+	{ "cfg_skp_min", 131, 128 },	   // cfg_skp_min[3..0]
+	{ "cfg_fast_pwrup", 127, 127 },	   // cfg_fast_pwrup
+	{ "Unused6", 126, 100 },	   // 0
+	{ "detected_n", 99, 99 },	   // detected_n
+	{ "detected_p", 98, 98 },	   // detected_p
+	{ "dbg_res_rx", 97, 94 },	   // dbg_res_rx[3..0]
+	{ "dbg_res_tx", 93, 90 },	   // dbg_res_tx[3..0]
+	{ "cfg_tx_pol_set", 89, 89 },	   // cfg_tx_pol_set
+	{ "cfg_tx_pol_clr", 88, 88 },	   // cfg_tx_pol_clr
+	{ "cfg_rx_pol_set", 87, 87 },	   // cfg_rx_pol_set
+	{ "cfg_rx_pol_clr", 86, 86 },	   // cfg_rx_pol_clr
+	{ "cfg_rxd_set", 85, 85 },	   // cfg_rxd_set
+	{ "cfg_rxd_clr", 84, 84 },	   // cfg_rxd_clr
+	{ "cfg_rxd_wait", 83, 80 },	   // cfg_rxd_wait[3..0]
+	{ "cfg_cdr_limit", 79, 79 },	   // cfg_cdr_limit
+	{ "cfg_cdr_rotate", 78, 78 },	   // cfg_cdr_rotate
+	{ "cfg_cdr_bw_ctl", 77, 76 },	   // cfg_cdr_bw_ctl[1..0]
+	{ "cfg_cdr_trunc", 75, 74 },	   // cfg_cdr_trunc[1..0]
+	{ "cfg_cdr_rqoffs", 73, 64 },	   // cfg_cdr_rqoffs[9..0]
+	{ "cfg_cdr_inc2", 63, 58 },	   // cfg_cdr_inc2[5..0]
+	{ "cfg_cdr_inc1", 57, 52 },	   // cfg_cdr_inc1[5..0]
+	{ "fusopt_voter_sync", 51, 51 },   // fusopt_voter_sync
+	{ "rndt", 50, 50 },		   // rndt
+	{ "hcya", 49, 49 },		   // hcya
+	{ "hyst", 48, 48 },		   // hyst
+	{ "idle_dac", 47, 45 },		   // idle_dac[2..0]
+	{ "bg_ref_sel", 44, 44 },	   // bg_ref_sel
+	{ "ic50dac", 43, 39 },		   // ic50dac[4..0]
+	{ "ir50dac", 38, 34 },		   // ir50dac[4..0]
+	{ "tx_rout_comp_bypass", 33, 33 }, // tx_rout_comp_bypass
+	{ "tx_rout_comp_value", 32, 29 },  // tx_rout_comp_value[3..0]
+	{ "tx_res_offset", 28, 25 },	   // tx_res_offset[3..0]
+	{ "rx_rout_comp_bypass", 24, 24 }, // rx_rout_comp_bypass
+	{ "rx_rout_comp_value", 23, 20 },  // rx_rout_comp_value[3..0]
+	{ "rx_res_offset", 19, 16 },	   // rx_res_offset[3..0]
+	{ "rx_cap_gen2", 15, 12 },	   // rx_cap_gen2[3..0]
+	{ "rx_eq_gen2", 11, 8 },	   // rx_eq_gen2[3..0]
+	{ "rx_cap_gen1", 7, 4 },	   // rx_cap_gen1[3..0]
+	{ "rx_eq_gen1", 3, 0 },		   // rx_eq_gen1[3..0]
+	{ NULL, -1, -1 }
+};
Signature · 1 line
2.35.1
#37 lore raw

PATCH 41/52 mips: octeon: Add cvmx-range.c

In reply to Stefan Roese

From: Aaron Williams <[email protected]>

Import cvmx-range.c from 2013 U-Boot. It will be used by the later added drivers to support networking on the MIPS Octeon II / III platforms.

---
 arch/mips/mach-octeon/cvmx-range.c | 344 +++++++++++++++++++++++++++++
 1 file changed, 344 insertions(+)
 create mode 100644 arch/mips/mach-octeon/cvmx-range.c
arch/mips/mach-octeon/cvmx-range.c new file +344 -0
new file mode 100644
index 000000000000..33dd95e7ab1a
@@ -0,0 +1,344 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018-2022 Marvell International Ltd.
+ */
+
+#include <log.h>
+#include <time.h>
+#include <linux/delay.h>
+
+#include <mach/cvmx-regs.h>
+#include <mach/cvmx-csr.h>
+#include <mach/cvmx-bootmem.h>
+#include <mach/octeon-model.h>
+#include <mach/cvmx-fuse.h>
+#include <mach/octeon-feature.h>
+#include <mach/cvmx-qlm.h>
+#include <mach/octeon_qlm.h>
+#include <mach/cvmx-pcie.h>
+#include <mach/cvmx-coremask.h>
+
+#include <mach/cvmx-global-resources.h>
+
+#include <mach/cvmx-pki.h>
+#include <mach/cvmx-helper.h>
+#include <mach/cvmx-helper-board.h>
+#include <mach/cvmx-helper-cfg.h>
+
+#include <mach/cvmx-range.h>
+
+#define CVMX_RANGE_AVAILABLE ((u64)-88)
+#define addr_of_element(base, index)					\
+	(1ull << 63 | ((base) + sizeof(u64) + (index) * sizeof(u64)))
+#define addr_of_size(base) (1ull << 63 | (base))
+
+static const int debug;
+
+int cvmx_range_memory_size(int nelements)
+{
+	return sizeof(u64) * (nelements + 1);
+}
+
+int cvmx_range_init(u64 range_addr, int size)
+{
+	u64 lsize = size;
+	u64 i;
+
+	cvmx_write64_uint64(addr_of_size(range_addr), lsize);
+	for (i = 0; i < lsize; i++) {
+		cvmx_write64_uint64(addr_of_element(range_addr, i),
+				    CVMX_RANGE_AVAILABLE);
+	}
+	return 0;
+}
+
+static int64_t cvmx_range_find_next_available(u64 range_addr, u64 index,
+					      int align)
+{
+	u64 size = cvmx_read64_uint64(addr_of_size(range_addr));
+	u64 i;
+
+	while ((index % align) != 0)
+		index++;
+
+	for (i = index; i < size; i += align) {
+		u64 r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+
+		if (debug)
+			debug("%s: index=%d owner=%llx\n", __func__, (int)i,
+			      (unsigned long long)r_owner);
+		if (r_owner == CVMX_RANGE_AVAILABLE)
+			return i;
+	}
+	return -1;
+}
+
+static int64_t cvmx_range_find_last_available(u64 range_addr, u64 index,
+					      u64 align)
+{
+	u64 size = cvmx_read64_uint64(addr_of_size(range_addr));
+	u64 i;
+
+	if (index == 0)
+		index = size - 1;
+
+	while ((index % align) != 0)
+		index++;
+
+	for (i = index; i > align; i -= align) {
+		u64 r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+
+		if (debug)
+			debug("%s: index=%d owner=%llx\n", __func__, (int)i,
+			      (unsigned long long)r_owner);
+		if (r_owner == CVMX_RANGE_AVAILABLE)
+			return i;
+	}
+	return -1;
+}
+
+int cvmx_range_alloc_ordered(u64 range_addr, u64 owner, u64 cnt,
+			     int align, int reverse)
+{
+	u64 i = 0, size;
+	s64 first_available;
+
+	if (debug)
+		debug("%s: range_addr=%llx  owner=%llx cnt=%d\n", __func__,
+		      (unsigned long long)range_addr,
+		      (unsigned long long)owner, (int)cnt);
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	while (i < size) {
+		u64 available_cnt = 0;
+
+		if (reverse)
+			first_available = cvmx_range_find_last_available(range_addr, i, align);
+		else
+			first_available = cvmx_range_find_next_available(range_addr, i, align);
+		if (first_available == -1)
+			return -1;
+		i = first_available;
+
+		if (debug)
+			debug("%s: first_available=%d\n", __func__, (int)first_available);
+		while ((available_cnt != cnt) && (i < size)) {
+			u64 r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+
+			if (r_owner == CVMX_RANGE_AVAILABLE)
+				available_cnt++;
+			i++;
+		}
+		if (available_cnt == cnt) {
+			u64 j;
+
+			if (debug)
+				debug("%s: first_available=%d available=%d\n",
+				      __func__,
+				      (int)first_available, (int)available_cnt);
+
+			for (j = first_available; j < first_available + cnt;
+			     j++) {
+				u64 a = addr_of_element(range_addr, j);
+
+				cvmx_write64_uint64(a, owner);
+			}
+			return first_available;
+		}
+	}
+
+	if (debug) {
+		debug("ERROR: %s: failed to allocate range cnt=%d\n",
+		      __func__, (int)cnt);
+		cvmx_range_show(range_addr);
+	}
+
+	return -1;
+}
+
+int cvmx_range_alloc(u64 range_addr, u64 owner, u64 cnt, int align)
+{
+	return cvmx_range_alloc_ordered(range_addr, owner, cnt, align, 0);
+}
+
+int cvmx_range_alloc_non_contiguos(u64 range_addr, u64 owner,
+				   u64 cnt, int elements[])
+{
+	u64 i = 0, size;
+	u64 element_index = 0;
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	for (i = 0; i < size; i++) {
+		u64 r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+
+		if (debug)
+			debug("%s: index=%d owner=%llx\n", __func__, (int)i,
+			      (unsigned long long)r_owner);
+		if (r_owner == CVMX_RANGE_AVAILABLE)
+			elements[element_index++] = (int)i;
+
+		if (element_index == cnt)
+			break;
+	}
+	if (element_index != cnt) {
+		if (debug)
+			debug("%s: failed to allocate non contiguous cnt=%d available=%d\n",
+			      __func__, (int)cnt, (int)element_index);
+		return -1;
+	}
+	for (i = 0; i < cnt; i++) {
+		u64 a = addr_of_element(range_addr, elements[i]);
+
+		cvmx_write64_uint64(a, owner);
+	}
+	return 0;
+}
+
+int cvmx_range_reserve(u64 range_addr, u64 owner, u64 base,
+		       u64 cnt)
+{
+	u64 i, size, r_owner;
+	u64 up = base + cnt;
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	if (up > size) {
+		debug("ERROR: %s: invalid base or cnt. range_addr=0x%llx, owner=0x%llx, size=%d base+cnt=%d\n",
+		      __func__, (unsigned long long)range_addr,
+		      (unsigned long long)owner,
+		      (int)size, (int)up);
+		return -1;
+	}
+	for (i = base; i < up; i++) {
+		r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+		if (debug)
+			debug("%s: %d: %llx\n",
+			      __func__, (int)i, (unsigned long long)r_owner);
+		if (r_owner != CVMX_RANGE_AVAILABLE) {
+			if (debug) {
+				debug("%s: resource already reserved base+cnt=%d %llu %llu %llx %llx %llx\n",
+				      __func__, (int)i, (unsigned long long)cnt,
+				      (unsigned long long)base,
+				      (unsigned long long)r_owner,
+				      (unsigned long long)range_addr,
+				      (unsigned long long)owner);
+			}
+			return -1;
+		}
+	}
+	for (i = base; i < up; i++)
+		cvmx_write64_uint64(addr_of_element(range_addr, i), owner);
+	return base;
+}
+
+int cvmx_range_free_with_owner(u64 range_addr, u64 owner)
+{
+	u64 i, size;
+	int found = -1;
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	for (i = 0; i < size; i++) {
+		u64 r_owner = cvmx_read64_uint64(addr_of_element(range_addr, i));
+
+		if (r_owner == owner) {
+			cvmx_write64_uint64(addr_of_element(range_addr, i),
+					    CVMX_RANGE_AVAILABLE);
+			found = 0;
+		}
+	}
+	return found;
+}
+
+int __cvmx_range_is_allocated(u64 range_addr, int bases[], int count)
+{
+	u64 i, cnt, size;
+	u64 r_owner;
+
+	cnt = count;
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	for (i = 0; i < cnt; i++) {
+		u64 base = bases[i];
+
+		if (base >= size) {
+			debug("ERROR: %s: invalid base or cnt size=%d base=%d\n",
+			      __func__, (int)size, (int)base);
+			return 0;
+		}
+		r_owner = cvmx_read64_uint64(addr_of_element(range_addr, base));
+		if (r_owner == CVMX_RANGE_AVAILABLE) {
+			if (debug) {
+				debug("%s: i=%d:base=%d is available\n",
+				      __func__, (int)i, (int)base);
+			}
+			return 0;
+		}
+	}
+	return 1;
+}
+
+int cvmx_range_free_mutiple(u64 range_addr, int bases[], int count)
+{
+	u64 i, cnt;
+
+	cnt = count;
+	if (__cvmx_range_is_allocated(range_addr, bases, count) != 1)
+		return -1;
+	for (i = 0; i < cnt; i++) {
+		u64 base = bases[i];
+
+		cvmx_write64_uint64(addr_of_element(range_addr, base),
+				    CVMX_RANGE_AVAILABLE);
+	}
+	return 0;
+}
+
+int cvmx_range_free_with_base(u64 range_addr, int base, int cnt)
+{
+	u64 i, size;
+	u64 up = base + cnt;
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	if (up > size) {
+		debug("ERROR: %s: invalid base or cnt size=%d base+cnt=%d\n",
+		      __func__, (int)size, (int)up);
+		return -1;
+	}
+	for (i = base; i < up; i++) {
+		cvmx_write64_uint64(addr_of_element(range_addr, i),
+				    CVMX_RANGE_AVAILABLE);
+	}
+	return 0;
+}
+
+u64 cvmx_range_get_owner(u64 range_addr, u64 base)
+{
+	u64 size = cvmx_read64_uint64(addr_of_size(range_addr));
+
+	if (base >= size) {
+		debug("ERROR: %s: invalid base or cnt size=%d base=%d\n",
+		      __func__, (int)size, (int)base);
+		return 0;
+	}
+	return cvmx_read64_uint64(addr_of_element(range_addr, base));
+}
+
+void cvmx_range_show(u64 range_addr)
+{
+	u64 pval, val, size, pindex, i;
+
+	size = cvmx_read64_uint64(addr_of_size(range_addr));
+	pval = cvmx_read64_uint64(addr_of_element(range_addr, 0));
+	pindex = 0;
+
+	debug("index=%d: owner %llx\n", (int)pindex, CAST_ULL(pval));
+
+	for (i = 1; i < size; i++) {
+		val = cvmx_read64_uint64(addr_of_element(range_addr, i));
+		if (val != pval) {
+			debug("index=%d: owner %llx\n", (int)pindex,
+			      CAST_ULL(pval));
+			pindex = i;
+			pval = val;
+		}
+	}
+	debug("index=%d: owner %llx\n", (int)pindex, CAST_ULL(pval));
+}
Signature · 1 line
2.35.1
#38 lore raw

PATCH 42/52 mips: octeon: Misc changes to existing C files for upcoming eth support

In reply to Stefan Roese

This patch includes misc changes to already present Octeon MIPS C files files, which are necessary for the upcoming ethernet support.

The changes are mostly:
- DM GPIO & I2C infrastructure
- Coding style cleanup while reworking of the code

---
 arch/mips/mach-octeon/cvmx-bootmem.c    |   3 +-
 arch/mips/mach-octeon/cvmx-helper-cfg.c |  67 +--
 arch/mips/mach-octeon/cvmx-helper-fdt.c | 645 +++++++++---------------
 arch/mips/mach-octeon/cvmx-helper.c     |  45 +-
 4 files changed, 279 insertions(+), 481 deletions(-)
arch/mips/mach-octeon/cvmx-bootmem.c +1 -2
index 9bd644d68bd8..52e58b4c1761 100644
@@ -1189,7 +1189,7 @@ s64 cvmx_bootmem_phy_mem_list_init(u64 mem_size,
 	if (mem_size > OCTEON_DDR1_SIZE) {
 		__cvmx_bootmem_phy_free(OCTEON_DDR1_BASE, OCTEON_DDR1_SIZE, 0);
 		__cvmx_bootmem_phy_free(OCTEON_DDR2_BASE,
-					mem_size - OCTEON_DDR1_SIZE, 0);
+					mem_size - OCTEON_DDR2_BASE, 0);
 	} else {
 		__cvmx_bootmem_phy_free(OCTEON_DDR1_BASE, mem_size, 0);
 	}
@@ -1349,7 +1349,6 @@ s64 cvmx_bootmem_phy_mem_list_init_multi(u8 node_mask,
 		addr += sizeof(struct cvmx_bootmem_named_block_desc);
 	}
 
-	// test-only: DEBUG ifdef???
 	cvmx_bootmem_phy_list_print();
 
 	return 1;
arch/mips/mach-octeon/cvmx-helper-cfg.c +16 -51

126 lines not on this page · raw message

arch/mips/mach-octeon/cvmx-helper-fdt.c +251 -394

782 lines not on this page · raw message

arch/mips/mach-octeon/cvmx-helper.c +11 -34

92 lines not on this page · raw message

Signature · 1 line
2.35.1
#39 lore raw

PATCH 43/52 mips: octeon: Makefile: Enable building of the newly added C files

In reply to Stefan Roese

This patch adds the newly added C files to the Makefile to enable compilation. This is done in a separate step, to not introduce build breakage while adding the single files with potentially missing externals.

---
 arch/mips/mach-octeon/Makefile | 35 +++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
arch/mips/mach-octeon/Makefile +34 -1
index 40ddab27eacd..6aa7b367416f 100644
@@ -12,13 +12,46 @@ obj-y += cvmx-coremask.o
 obj-y += cvmx-bootmem.o
 obj-y += bootoctlinux.o
 
-# QLM related code
+# Misc Octeon C files, mostly for QLM & ethernet support
+obj-y += cvmx-agl.o
+obj-y += cvmx-fpa.o
+obj-y += cvmx-fpa-resource.o
+obj-y += cvmx-fau-compat.o
+obj-y += cvmx-global-resources.o
+obj-y += cvmx-cmd-queue.o
+obj-y += cvmx-helper-agl.o
+obj-y += cvmx-helper-bgx.o
+obj-y += cvmx-helper-board.o
 obj-y += cvmx-helper-cfg.o
 obj-y += cvmx-helper-fdt.o
+obj-y += cvmx-helper-fpa.o
+obj-y += cvmx-helper-ilk.o
+obj-y += cvmx-helper-ipd.o
 obj-y += cvmx-helper-jtag.o
+obj-y += cvmx-helper-loop.o
+obj-y += cvmx-helper-npi.o
+obj-y += cvmx-helper-pki.o
+obj-y += cvmx-helper-pko.o
+obj-y += cvmx-helper-pko3.o
+obj-y += cvmx-helper-rgmii.o
+obj-y += cvmx-helper-sfp.o
+obj-y += cvmx-helper-sgmii.o
 obj-y += cvmx-helper-util.o
+obj-y += cvmx-helper-xaui.o
 obj-y += cvmx-helper.o
+obj-y += cvmx-ilk.o
+obj-y += cvmx-ipd.o
 obj-y += cvmx-pcie.o
+obj-y += cvmx-pki.o
+obj-y += cvmx-pki-resources.o
+obj-y += cvmx-pko.o
+obj-y += cvmx-pko-internal-ports-range.o
+obj-y += cvmx-pko3.o
+obj-y += cvmx-pko3-compat.o
+obj-y += cvmx-pko3-resources.o
+obj-y += cvmx-pko3-queue.o
+obj-y += cvmx-range.o
 obj-y += cvmx-qlm.o
+obj-y += cvmx-qlm-tables.o
 obj-y += octeon_fdt.o
 obj-y += octeon_qlm.o
Signature · 1 line
2.35.1
#40 lore raw

PATCH 44/52 mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()

In reply to Stefan Roese

Call octeon_bootmem_init() earlier in the boot process, so that this bootmemory infrastructure is already initialized when e.g. the networking support gets probed.

---
 arch/mips/Kconfig           |  1 +
 arch/mips/mach-octeon/cpu.c | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
arch/mips/Kconfig +1 -0
index 28234aa0bb6c..34376511daee 100644
@@ -101,6 +101,7 @@ config ARCH_JZ47XX
 
 config ARCH_OCTEON
 	bool "Support Marvell Octeon CN7xxx platforms"
+	select ARCH_EARLY_INIT_R
 	select CPU_CAVIUM_OCTEON
 	select DISPLAY_CPUINFO
 	select DMA_ADDR_T_64BIT
arch/mips/mach-octeon/cpu.c +12 -1
index 6cfcc3eae04e..fffd9dfb8580 100644
@@ -393,14 +393,25 @@ static int init_bootcmd_console(void)
 	return ret;
 }
 
-int arch_misc_init(void)
+int arch_early_init_r(void)
 {
 	int ret;
 
+	/*
+	 * Needs to be called pretty early, so that e.g. networking etc
+	 * can access the bootmem infrastructure
+	 */
 	ret = octeon_bootmem_init();
 	if (ret)
 		return ret;
 
+	return 0;
+}
+
+int arch_misc_init(void)
+{
+	int ret;
+
 	ret = octeon_configure_load_memory();
 	if (ret)
 		return ret;
Signature · 1 line
2.35.1
#41 lore raw

PATCH 45/52 mips: octeon: cpu.c: Implement configure_lmtdma_window()

In reply to Stefan Roese

Import configure_lmtdma_window from Marvell 2013 U-Boot as it's needed for network functionality.

---
 arch/mips/mach-octeon/cpu.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
arch/mips/mach-octeon/cpu.c +33 -1
index fffd9dfb8580..1bdc6cd72903 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2020 Marvell International Ltd.
+ * Copyright (C) 2020-2022 Marvell International Ltd.
  */
 
 #include <dm.h>
@@ -17,6 +17,8 @@
 #include <mach/cvmx-bootmem.h>
 #include <mach/cvmx-regs.h>
 #include <mach/cvmx-sata-defs.h>
+#include <mach/octeon-model.h>
+#include <mach/octeon-feature.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -393,6 +395,33 @@ static int init_bootcmd_console(void)
 	return ret;
 }
 
+static void configure_lmtdma_window(void)
+{
+	u64 tmp;
+	u64 addr;
+	u64 end_addr;
+
+	CVMX_MF_CVM_MEM_CTL(tmp);
+	tmp &= ~0x1ffull;
+	tmp |= 0x104ull;
+
+	/* enable LMTDMA */
+	tmp |= (1ull << 51);
+	/* configure scratch line 2 for LMT */
+	/* TODO: reserve this scratch line, so that others will not use it */
+	/* TODO: store LMTLINE in global var */
+	tmp |= (CVMX_PKO_LMTLINE << 45);
+	/* clear LMTLINE in scratch */
+	addr = CVMX_PKO_LMTLINE * CVMX_CACHE_LINE_SIZE;
+	end_addr = addr + CVMX_CACHE_LINE_SIZE;
+
+	while (addr < end_addr) {
+		*CASTPTR(volatile u64, addr + CVMX_SCRATCH_BASE) = (u64)0;
+		addr += 8;
+	}
+	CVMX_MT_CVM_MEM_CTL(tmp);
+}
+
 int arch_early_init_r(void)
 {
 	int ret;
@@ -405,6 +434,9 @@ int arch_early_init_r(void)
 	if (ret)
 		return ret;
 
+	if (octeon_has_feature(OCTEON_FEATURE_PKO3))
+		configure_lmtdma_window();
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
#42 lore raw

PATCH 46/52 mips: octeon: octeon_common.h: Move init SP because of increased image size

In reply to Stefan Roese

This patch moves CONFIG_SYS_INIT_SP_OFFSET to a higher address so that it does not interfere with larger U-Boot images. This was noticed, while adding network support to the EBB7304 board.

---
 include/configs/octeon_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/octeon_common.h +1 -1
index 23bb4f676f8e..884745d514a3 100644
@@ -8,7 +8,7 @@
 #define __OCTEON_COMMON_H__
 
 #if defined(CONFIG_RAM_OCTEON)
-#define CONFIG_SYS_INIT_SP_OFFSET	0x20100000
+#define CONFIG_SYS_INIT_SP_OFFSET	0x20180000
 #else
 /* No DDR init -> run in L2 cache with limited resources */
 #define CONFIG_SYS_INIT_SP_OFFSET	0x00180000
Signature · 1 line
2.35.1
#43 lore raw

PATCH 47/52 mips: octeon: mrvl, cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes

In reply to Stefan Roese

Add the Octeon ethernet (BGX) and SMI DT node to the dtsi file.

---
 arch/mips/dts/mrvl,cn73xx.dtsi | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
arch/mips/dts/mrvl,cn73xx.dtsi +35 -0
index 2a17f7a6a63e..77f3548a326a 100644
@@ -267,5 +267,40 @@
 				interrupts = <0x6c010 4>;
 			};
 		};
+
+		/* SMI1 */
+		smi1: mdio@1180000003880 {
+			compatible = "cavium,octeon-3860-mdio";
+			reg = <0x11800 0x00003880 0x0 0x40>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		/* BGX 0 */
+		bgx0: ethernet-mac-nexus@11800e0000000 {
+			compatible = "cavium,octeon-7890-bgx";
+			reg = <0x11800 0xe0000000 0x0 0x1000000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		/* BGX 1 */
+		bgx1: ethernet-mac-nexus@11800e1000000 {
+			compatible = "cavium,octeon-7890-bgx";
+			reg = <0x11800 0xe1000000 0x0 0x1000000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
+		/* BGX 2*/
+		bgx2: ethernet-mac-nexus@11800e2000000 {
+			compatible = "cavium,octeon-7890-bgx";
+			reg = <0x11800 0xe2000000 0x0 0x1000000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
 	};
 };
Signature · 1 line
2.35.1
#44 lore raw

PATCH 48/52 mips: octeon: mrvl, octeon-ebb7304.dts: Add ethernet DT support

In reply to Stefan Roese

Add the Octeon ethernet (BGX), SMI and PHY DT nodes to the EBB7304 dts file to enable ethernet support on this board.

---
 arch/mips/dts/mrvl,octeon-ebb7304.dts | 45 +++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
arch/mips/dts/mrvl,octeon-ebb7304.dts +45 -0
index fda559d8629d..08247eb4e0ee 100644
@@ -201,3 +201,48 @@
 		cd-gpios = <&gpio 25 1>; /* active low */
 	};
 };
+
+/* SMI_1 -- Available on rev 2 and later boards */
+&smi1 {
+	/**
+	 * The phy names are broken down as follows:
+	 * (m)phyxxyzzs
+	 * where:
+	 *	xx = 01 for SGMII, 10 for DXAUI, 20 for RXAUI
+	 *	     and 40 for XFI/LXAUI
+	 *	y = QLM/DLM number
+	 *	zz = PHY address (decimal)
+	 *	s = sub-phy number in the case of the Cortina
+	 *	    PHY
+	 * a mphy is a nexus phy that contains one or more
+	 * sub-phys, for example the Cortina CS4223.
+	 */
+
+	/* QLM 2 */
+	phy01208: ethernet-phy@01208 {
+		reg = <8>;
+		compatible = "marvell,88e1240", "ethernet-phy-ieee802.3-c22";
+
+		marvell,reg-init = <3 0x10 0 0x8665>,
+				   <3 0x11 0 0x00aa>,
+				   <3 0x12 0 0x4105>,
+				   <3 0x13 0 0x8a08>;
+
+		interrupt-parent = <&gpio>;
+		interrupts = <12 8>; /* Pin 12, active low */
+	};
+};
+
+/* BGX 0 */
+&bgx0 {
+	status = "okay";
+	phy-handle = <&phy01208>; /* put phy-handle in BGX node and MAC node */
+
+	/* SerDes 0, may differ from PCS Lane/LMAC */
+	eth0: ethernet-mac@D {
+		compatible = "cavium,octeon-7890-bgx-port";
+		reg = <0>;
+		local-mac-address = [ 00 00 00 00 00 00 ];
+		phy-handle = <&phy01208>;
+	};
+};
Signature · 1 line
2.35.1
#45 lore raw

PATCH 49/52 mips: octeon: mrvl, octeon-nic23.dts: Add ethernet DT support

In reply to Stefan Roese

Add the Octeon ethernet (BGX) and SFP DT nodes to the NIC23 dts file to enable ethernet support on this board.

---
 arch/mips/dts/mrvl,octeon-nic23.dts | 238 ++++++++++++++++++++++++++++
 1 file changed, 238 insertions(+)
arch/mips/dts/mrvl,octeon-nic23.dts +238 -0
index 72ef56d834e4..dfbd51c92468 100644
@@ -118,11 +118,208 @@
 &i2c0 {
 	u-boot,dm-pre-reloc;	/* Needed early for DDR SPD EEPROM */
 	clock-frequency = <100000>;
+
+	sfp0eeprom: eeprom@50 {
+		compatible = "atmel,24c01";
+		reg = <0x50>;
+	};
+
+	sfp0alerts: eeprom@51 {
+		compatible = "atmel,24c01";
+		reg = <0x51>;
+	};
 };
 
 &i2c1 {
 	u-boot,dm-pre-reloc;	/* Needed early for DDR SPD EEPROM */
 	clock-frequency = <100000>;
+
+	vitesse@10 {
+		compatible = "vitesse,vsc7224";
+		reg = <0x10>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* Note that reset is active high with this device */
+		reset = <&gpio 7 0>;
+
+		/* LoS pin can be pulled low when there is a loss of signal */
+		los = <&gpio 6 0>;
+
+		vitesse,reg-init =
+			/* Clear all masks */
+			/* Page select FSYNC0 (0x30) */
+			<0x7f 0x0030>,
+			/* Set FSYNC0 for 10.3125Gbps */
+			<0x80 0x2841>,	/* See Table 3. */
+			<0x81 0x0008>,
+			<0x82 0xc000>,
+			<0x83 0x0010>,
+			<0x84 0x1d00>,
+
+			/* All channels Rx settings set equally */
+			<0x7f 0x0050>,
+			/* Shrink EQ_BUFF */
+			<0x82 0x0014>,
+			/* Set EQVGA_ADAP = 1 (enable EQVGA circuitry),
+			 * USE_UNIT_GAIN = 1 (EQVGA is in unity gain),
+			 * USE_LPF = 0 (VGA adapt not using LPF),
+			 * USE_EQVGA = 1
+			<0x89 0x7f13>,
+			/* Select min DFE Delay (DFE_DELAY) */
+			<0x90 0x5785>,
+			/* Set DFE 1-3 limit (DXMAX) = 32dec,
+			 * AP Max limit = 127 decimal
+			 */
+			<0x92 0x207f>,
+			/* Set AP Min limit = 32 decimal */
+			<0x93 0x2000>,
+			/* Set DFE Averaging to the slowest (DFE_AVG) */
+			<0x94 0x0031>,
+			/* Set Inductor Bypass OD_IND_BYP = 0 & fastest Rise/Fall */
+			<0x9c 0x0000>,
+			/* Setting DFE Boost = none. Must set for
+			 * rev C (if DFE in adapt mode)
+			 */
+			<0xaa 0x0888>,
+			/* Setting EQ Min = 8 & Max limit = 72 dec.
+			 * Must set for rev C, otherwise EQ is 0
+			 * (if EQ is in adaptive mode)
+			 */
+			<0xa8 0x2408>,
+			/* Setting EQVGA = 96, when in EQVGA manual mode */
+			<0xa9 0x0060>,
+			/* Setting SW_BFOCM, bits 15:14 to 01 */
+			<0x87 0x4021>,
+			/* Turn off adaptive input equalization
+			 * and VGA adaptive algorithm control.
+			*/
+			<0x89 0x7313>,
+			/* Turn on adaptive input equalization
+			 * and VGA adaptive algorithm control.
+			*/
+			<0x89 0x7f13>;
+
+		vitesse-channel@0 {
+			compatible = "vitesse,vsc7224-channel";
+			reg = <0>;
+			direction-tx;
+			sfp-mac = <&eth0>;
+
+			/* TAP settings.  The format of this is as
+			 * follows:
+			 * - cable length in meters, 0 = active or
+			 *   optical module
+			 * - maintap value
+			 * - pretap value
+			 * - posttap value
+			 *
+			 * For the cable length, the value will apply
+			 * for that cable length and greater until the
+			 * next largest cable length specified.  These
+			 * values must be ordered first by channel mask
+			 * then by cable length.  These are typically
+			 * set for the transmit channels, not the
+			 * receive channels.
+			 */
+			taps = <0 0x0013 0x000f 0x0000>,
+			       <1 0x001f 0x000f 0x0004>,
+			       <3 0x0014 0x000b 0x0004>,
+			       <5 0x0014 0x0009 0x0006>,
+			       <7 0x0014 0x000f 0x0000>,
+			       <10 0x0012 0x000b 0x0013>;
+		};
+
+		vitesse-channel@1 {
+			compatible = "vitesse,vsc7224-channel";
+			reg = <1>;
+			/* Ignore mod_abs and module */
+			direction-rx;
+			sfp-mac = <&eth0>;
+
+			/* Disable pre-tap */
+			pretap-disable;
+
+			/* Disable post-tap */
+			posttap-disable;
+
+			/* Taps has the following fields:
+			 * - cable length (ignored for rx)
+			 * - main tap value
+			 * - pre tap value
+			 * - post tap value
+			 *
+			 * NOTE: if taps are disabled then they
+			 *       are not programmed.
+			 */
+			taps = <0 0x0a 0x0b 0x10>;
+		};
+
+		vitesse-channel@2 {
+			compatible = "vitesse,vsc7224-channel";
+			reg = <2>;
+			direction-tx;
+			sfp-mac = <&eth1>;
+
+			/* TAP settings.  The format of this is as
+			 * follows:
+			 * - cable length in meters, 0 = active or
+			 *   optical module
+			 * - maintap value
+			 * - pretap value
+			 * - posttap value
+			 *
+			 * For the cable length, the value will apply
+			 * for that cable length and greater until the
+			 * next largest cable length specified.  These
+			 * values must be ordered first by channel mask
+			 * then by cable length.  These are typically
+			 * set for the transmit channels, not the
+			 * receive channels.
+			 */
+			taps = <0 0x0013 0x000f 0x0000>,
+			       <1 0x001f 0x000f 0x0004>,
+			       <3 0x0014 0x000b 0x0004>,
+			       <5 0x0014 0x0009 0x0006>,
+			       <7 0x0014 0x000f 0x0000>,
+			       <10 0x0012 0x000b 0x0013>;
+		};
+
+		vitesse-channel@3 {
+			compatible = "vitesse,vsc7224-channel";
+			reg = <3>;
+			/* Ignore mod_abs and module */
+			direction-rx;
+			sfp-mac = <&eth1>;
+
+			/* Disable pre-tap */
+			pretap-disable;
+
+			/* Disable post-tap */
+			posttap-disable;
+
+			/* Taps has the following fields:
+			 * - cable length (ignored for rx)
+			 * - main tap value
+			 * - pre tap value
+			 * - post tap value
+			 *
+			 * NOTE: if taps are disabled then they
+			 *       are not programmed.
+			 */
+			taps = <0 0x0a 0x0b 0x10>;
+		};
+	};
+
+	sfp1eeprom: eeprom@50 {
+		compatible = "atmel,24c01";
+		reg = <0x50>;
+	};
+
+	sfp1alerts: eeprom@51 {
+		compatible = "atmel,24c01";
+		reg = <0x51>;
+	};
 };
 
 &mmc {
@@ -151,6 +348,26 @@
 		compatible = "marvell,pci-bootcmd";
 		status = "okay";
 	};
+
+	sfp0: sfp-slot@0 {
+		compatible = "ethernet,sfp-slot";
+		tx_disable = <&gpio 16 0>;
+		mod_abs = <&gpio 17 0>;
+		tx_error = <&gpio 19 0>;
+		rx_los = <&gpio 18 0>;
+		eeprom = <&sfp0eeprom>;
+		diag = <&sfp0alerts>;
+	};
+
+	sfp1: sfp-slot@1 {
+		compatible = "ethernet,sfp-slot";
+		tx_disable = <&gpio 21 0>;
+		mod_abs = <&gpio 22 0>;
+		tx_error = <&gpio 24 0>;
+		rx_los = <&gpio 23 0>;
+		eeprom = <&sfp1eeprom>;
+		diag = <&sfp1alerts>;
+	};
 };
 
 &spi {
@@ -160,3 +377,24 @@
 		reg = <0>;
 	};
 };
+
+/* BGX 2 */
+&bgx2 {
+	status = "okay";
+
+	/* SerDes 0, may differ from PCS Lane/LMAC */
+	eth0: ethernet-mac@0 {
+		compatible = "cavium,octeon-7890-bgx-port";
+		reg = <0>;
+		local-mac-address = [ 00 00 00 00 00 00 ];
+		sfp-slot = <&sfp0>;
+	};
+
+	/* SerDes 1, may differ from PCS Lane/LMAC */
+	eth1: ethernet-mac@1 {
+		compatible = "cavium,octeon-7890-bgx-port";
+		reg = <1>;
+		local-mac-address = [ 00 00 00 00 00 00 ];
+		sfp-slot = <&sfp1>;
+	};
+};
Signature · 1 line
2.35.1
#46 lore raw

PATCH 50/52 net: Add ethernet support for MIPS Octeon

In reply to Stefan Roese

This patchs adds the ethernet & MDIO driver for the MIPS Octeon II / III SoC platform. Please note that these drivers are based on the 2013 U-Boot version from Marvell and make use of the platform supported helper functions for the ethernet functionality, including stuff like SFP handling.

Cc Ramon Fried <[email protected]>
Cc Joe Hershberger <[email protected]>
---
 drivers/net/Kconfig              |    7 +
 drivers/net/Makefile             |    1 +
 drivers/net/octeon/Makefile      |    6 +
 drivers/net/octeon/octeon_eth.c  | 1060 ++++++++++++++++++++++++++++++
 drivers/net/octeon/octeon_mdio.c |  226 +++++++
 5 files changed, 1300 insertions(+)
 create mode 100644 drivers/net/octeon/Makefile
 create mode 100644 drivers/net/octeon/octeon_eth.c
 create mode 100644 drivers/net/octeon/octeon_mdio.c
drivers/net/Kconfig +7 -0
index 71e0cbafb412..76cf61f4c862 100644
@@ -485,6 +485,13 @@ config MT7628_ETH
 	  The MediaTek MT7628 ethernet interface is used on MT7628 and
 	  MT7688 based boards.
 
+config NET_OCTEON
+	bool "MIPS Octeon ethernet support"
+	depends on ARCH_OCTEON
+	help
+	  You must select Y to enable network device support for
+	  MIPS Octeon SoCs. If unsure, say n
+
 config NET_OCTEONTX
 	bool "OcteonTX Ethernet support"
 	depends on ARCH_OCTEONTX
drivers/net/Makefile +1 -0
index a6d0c23f02d3..63144b27bf02 100644
@@ -72,6 +72,7 @@ obj-$(CONFIG_MVNETA) += mvneta.o
 obj-$(CONFIG_MVPP2) += mvpp2.o
 obj-$(CONFIG_NATSEMI) += natsemi.o
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
+obj-$(CONFIG_NET_OCTEON) += octeon/
 obj-$(CONFIG_NET_OCTEONTX) += octeontx/
 obj-$(CONFIG_NET_OCTEONTX2) += octeontx2/
 obj-$(CONFIG_NS8382X) += ns8382x.o
drivers/net/octeon/Makefile new file +6 -0
new file mode 100644
index 000000000000..c573411a6293
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier:    GPL-2.0+
+#
+# Copyright (C) 2018-2022 Marvell International Ltd.
+#
+
+obj-$(CONFIG_NET_OCTEON) += octeon_eth.o octeon_mdio.o
drivers/net/octeon/octeon_eth.c new file +1060 -0

1,060 lines not on this page · raw message

drivers/net/octeon/octeon_mdio.c new file +226 -0

226 lines not on this page · raw message

Signature · 1 line
2.35.1
#47 lore raw
In reply to Stefan Roese

Add Daniel to Cc (sorry, I forgot you Daniel).

Thanks,
Stefan

Quoted 222 lines · Stefan Roese

This patchset adds the networking files and drivers including device helper headers and C files. Please excuse the massive amount of files in this patch series. Also the sometimes huge files (mostly headers with register definitions) that I needed to include.

The infrastructure code with all the headers is ported mistly without any intended functional changes from the 2013 Cavium / Marvell U-Boot version. It has undergone many hours of extensive code cleanup and reformatting. Some of it done by using tools (checkpatch, Lindent, clang format etc) and also some of it done manually, as I couldn't find some tools that could do the needed work in a reliable and functional way. The result is that checkpatch now only throws a "few" warnings that are left. Some of those can't be removed without an even more extensive cleanup / rewrite of the code, like the addition of typedefs.

The added header, helper and infrastructure files in the first part of the patch-series (patches 1-43) are the foundation, that is used by the main Octeon U-Boot ethernet driver (patch 50/52). Patches 47-49 add the DT nodes and properties to the corresponding dtsi / dts files. Patches 51 & 52 finally enable the ethernet support both MIPS Octeon boards, EBB7304 & NIC23.

All this is tested on the 2 Cavium / Marvell MIPS Octeon boards:
EBB7304 & NIC23

This patchset including the small Marvell PHY patches is available in this gitlab branch:

https://source.denx.de/u-boot/custodians/u-boot-marvell/-/tree/mips-octeon-ethernet-v1-2022-03-30

Thanks,
Stefan

Aaron Williams (40):
mips: octeon: Add misc cvmx-* header files
mips: octeon: Add cvmx-ilk-defs.h header file
mips: octeon: Add cvmx-iob-defs.h header file
mips: octeon: Add cvmx-lbk-defs.h header file
mips: octeon: Add cvmx-npei-defs.h header file
mips: octeon: Add cvmx-pcsxx-defs.h header file
mips: octeon: Add cvmx-xcv-defs.h header file
mips: octeon: Add cvmx-helper-agl.c
mips: octeon: Add cvmx-helper-bgx.c
mips: octeon: Add cvmx-helper-board.c
mips: octeon: Add cvmx-helper-fpa.c
mips: octeon: Add cvmx-helper-igl.c
mips: octeon: Add cvmx-helper-ipd.c
mips: octeon: Add cvmx-helper-loop.c
mips: octeon: Add cvmx-helper-npi.c
mips: octeon: Add cvmx-helper-pki.c
mips: octeon: Add cvmx-helper-pko.c
mips: octeon: Add cvmx-helper-pko3.c
mips: octeon: Add cvmx-helper-rgmii.c
mips: octeon: Add cvmx-helper-sgmii.c
mips: octeon: Add cvmx-helper-sfp.c
mips: octeon: Add cvmx-helper-xaui.c
mips: octeon: Add cvmx-agl.c
mips: octeon: Add cvmx-cmd-queue.c
mips: octeon: Add cvmx-fau-compat.c
mips: octeon: Add cvmx-fpa.c
mips: octeon: Add cvmx-fpa-resource.c
mips: octeon: Add cvmx-global-resource.c
mips: octeon: Add cvmx-ilk.c
mips: octeon: Add cvmx-ipd.c
mips: octeon: Add cvmx-pki.c
mips: octeon: Add cvmx-pki-resources.c
mips: octeon: Add cvmx-pko.c
mips: octeon: Add cvmx-pko3.c
mips: octeon: Add cvmx-pko3-queue.c
mips: octeon: Add cvmx-pko3-compat.c
mips: octeon: Add cvmx-pko3-resources.c
mips: octeon: Add cvmx-pko-internal-ports-range.c
mips: octeon: Add cvmx-qlm-tables.c
mips: octeon: Add cvmx-range.c

Stefan Roese (12):
mips: octeon: Misc changes to existing headers for upcoming eth
support
mips: octeon: Misc changes to existing C files for upcoming eth
support
mips: octeon: Makefile: Enable building of the newly added C files
mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()
mips: octeon: cpu.c: Implement configure_lmtdma_window()
mips: octeon: octeon_common.h: Move init SP because of increased image
size
mips: octeon: mrvl,cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
mips: octeon: mrvl,octeon-ebb7304.dts: Add ethernet DT support
mips: octeon: mrvl,octeon-nic23.dts: Add ethernet DT support
net: Add ethernet support for MIPS Octeon
mips: octeon: ebb7304: Enable ethernet support
mips: octeon: nic23: Enable ethernet support

  arch/mips/Kconfig                             |    1 +
  arch/mips/dts/mrvl,cn73xx.dtsi                |   35 +
  arch/mips/dts/mrvl,octeon-ebb7304.dts         |   45 +
  arch/mips/dts/mrvl,octeon-nic23.dts           |  238 ++
  arch/mips/mach-octeon/Makefile                |   35 +-
  arch/mips/mach-octeon/cpu.c                   |   47 +-
  arch/mips/mach-octeon/cvmx-agl.c              |  216 +
  arch/mips/mach-octeon/cvmx-bootmem.c          |    3 +-
  arch/mips/mach-octeon/cvmx-cmd-queue.c        |  449 +++
  arch/mips/mach-octeon/cvmx-fau-compat.c       |   53 +
  arch/mips/mach-octeon/cvmx-fpa-resource.c     |  305 ++
  arch/mips/mach-octeon/cvmx-fpa.c              | 1672 ++++++++
  arch/mips/mach-octeon/cvmx-global-resources.c |  639 +++
  arch/mips/mach-octeon/cvmx-helper-agl.c       |  231 ++
  arch/mips/mach-octeon/cvmx-helper-bgx.c       | 3215 +++++++++++++++
  arch/mips/mach-octeon/cvmx-helper-board.c     | 2030 ++++++++++
  arch/mips/mach-octeon/cvmx-helper-cfg.c       |   67 +-
  arch/mips/mach-octeon/cvmx-helper-fdt.c       |  645 ++-
  arch/mips/mach-octeon/cvmx-helper-fpa.c       |  329 ++
  arch/mips/mach-octeon/cvmx-helper-ilk.c       |  926 +++++
  arch/mips/mach-octeon/cvmx-helper-ipd.c       |  313 ++
  arch/mips/mach-octeon/cvmx-helper-loop.c      |  178 +
  arch/mips/mach-octeon/cvmx-helper-npi.c       |  146 +
  arch/mips/mach-octeon/cvmx-helper-pki.c       | 2156 ++++++++++
  arch/mips/mach-octeon/cvmx-helper-pko.c       |  312 ++
  arch/mips/mach-octeon/cvmx-helper-pko3.c      | 1252 ++++++
  arch/mips/mach-octeon/cvmx-helper-rgmii.c     |  431 ++
  arch/mips/mach-octeon/cvmx-helper-sfp.c       | 1877 +++++++++
  arch/mips/mach-octeon/cvmx-helper-sgmii.c     |  781 ++++
  arch/mips/mach-octeon/cvmx-helper-xaui.c      |  587 +++
  arch/mips/mach-octeon/cvmx-helper.c           |   45 +-
  arch/mips/mach-octeon/cvmx-ilk.c              | 1618 ++++++++
  arch/mips/mach-octeon/cvmx-ipd.c              |  690 ++++
  arch/mips/mach-octeon/cvmx-pki-resources.c    |  519 +++
  arch/mips/mach-octeon/cvmx-pki.c              | 1619 ++++++++
  .../cvmx-pko-internal-ports-range.c           |  164 +
  arch/mips/mach-octeon/cvmx-pko.c              | 1110 ++++++
  arch/mips/mach-octeon/cvmx-pko3-compat.c      |  656 +++
  arch/mips/mach-octeon/cvmx-pko3-queue.c       | 1331 ++++++
  arch/mips/mach-octeon/cvmx-pko3-resources.c   |  229 ++
  arch/mips/mach-octeon/cvmx-pko3.c             | 2143 ++++++++++
  arch/mips/mach-octeon/cvmx-qlm-tables.c       |  292 ++
  arch/mips/mach-octeon/cvmx-range.c            |  344 ++
  arch/mips/mach-octeon/include/mach/cvmx-agl.h |   45 +
  .../mach-octeon/include/mach/cvmx-bootmem.h   |    3 +-
  .../mach-octeon/include/mach/cvmx-config.h    |  128 +
  arch/mips/mach-octeon/include/mach/cvmx-fau.h |  581 +++
  arch/mips/mach-octeon/include/mach/cvmx-fpa.h |    3 +-
  .../mips/mach-octeon/include/mach/cvmx-fpa3.h |   37 -
  .../include/mach/cvmx-helper-board.h          |    6 +-
  .../include/mach/cvmx-helper-fdt.h            |   40 +-
  .../include/mach/cvmx-helper-pko.h            |    2 +-
  .../mach-octeon/include/mach/cvmx-helper.h    |   20 +
  .../mach-octeon/include/mach/cvmx-ilk-defs.h  | 2269 +++++++++++
  .../mach-octeon/include/mach/cvmx-iob-defs.h  | 1328 ++++++
  .../mach-octeon/include/mach/cvmx-lbk-defs.h  |  157 +
  .../mips/mach-octeon/include/mach/cvmx-mdio.h |  516 +++
  .../mach-octeon/include/mach/cvmx-npei-defs.h | 3550 +++++++++++++++++
  .../include/mach/cvmx-pcsxx-defs.h            |  787 ++++
  .../include/mach/cvmx-pki-cluster.h           |  343 ++
  arch/mips/mach-octeon/include/mach/cvmx-pko.h |  213 +
  .../include/mach/cvmx-pko3-resources.h        |   36 +
  .../mips/mach-octeon/include/mach/cvmx-pko3.h | 1052 +++++
  .../mach-octeon/include/mach/cvmx-range.h     |   23 +
  .../mips/mach-octeon/include/mach/cvmx-regs.h |  100 +-
  .../mach-octeon/include/mach/cvmx-xcv-defs.h  |  226 ++
  .../mach-octeon/include/mach/octeon_eth.h     |   54 +-
  board/Marvell/octeon_nic23/board.c            |   87 +-
  configs/octeon_ebb7304_defconfig              |    7 +
  configs/octeon_nic23_defconfig                |   10 +-
  drivers/net/Kconfig                           |    7 +
  drivers/net/Makefile                          |    1 +
  drivers/net/octeon/Makefile                   |    6 +
  drivers/net/octeon/octeon_eth.c               | 1060 +++++
  drivers/net/octeon/octeon_mdio.c              |  226 ++
  include/configs/octeon_common.h               |    2 +-
  include/configs/octeon_ebb7304.h              |    2 +
  77 files changed, 42315 insertions(+), 586 deletions(-)

create mode 100644 arch/mips/mach-octeon/cvmx-agl.c
create mode 100644 arch/mips/mach-octeon/cvmx-cmd-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-fau-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa-resource.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa.c
create mode 100644 arch/mips/mach-octeon/cvmx-global-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-agl.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-bgx.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-board.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-fpa.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ilk.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ipd.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-loop.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-npi.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pki.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko3.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-rgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sfp.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-xaui.c create mode 100644 arch/mips/mach-octeon/cvmx-ilk.c
create mode 100644 arch/mips/mach-octeon/cvmx-ipd.c
create mode 100644 arch/mips/mach-octeon/cvmx-pki-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pki.c
create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-range.c create mode 100644 arch/mips/mach-octeon/cvmx-pko.c
create mode 100644 arch/mips/mach-octeon/cvmx-pko3-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3.c
create mode 100644 arch/mips/mach-octeon/cvmx-qlm-tables.c create mode 100644 arch/mips/mach-octeon/cvmx-range.c
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-agl.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-config.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fau.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-ilk-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-iob-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-lbk-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-mdio.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-npei-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pcsxx-defs.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pki-cluster.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3-resources.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-range.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-xcv-defs.h create mode 100644 drivers/net/octeon/Makefile
create mode 100644 drivers/net/octeon/octeon_eth.c
create mode 100644 drivers/net/octeon/octeon_mdio.c

#48 lore raw

PATCH 51/52 mips: octeon: ebb7304: Enable ethernet support

In reply to Stefan Roese

This patch enables the Kconfig symbols needed for full ethernet support on the EBB7304. Also the PHY autonegotiation timeout is increased, as the default 5 seconds are sometime a bit short. With this, ethernet can be used on this board. Here an example of a tftp load:

=> tftp ffffffff81000000 big
ethernet-mac-nexus@11800e0000000 Waiting for PHY auto negotiation to complete....... done Using ethernet-mac-nexus@11800e0000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.243
Filename 'big'.
Load address: 0xffffffff81000000
Loading: ################################################## 10 MiB

         13.2 MiB/s

done
Bytes transferred = 10485760 (a00000 hex)

---
 configs/octeon_ebb7304_defconfig | 7 +++++++
 include/configs/octeon_ebb7304.h | 2 ++
 2 files changed, 9 insertions(+)
configs/octeon_ebb7304_defconfig +7 -0
index 9824f8b97ae5..3d9bbaaab4df 100644
@@ -25,6 +25,7 @@ CONFIG_CMD_PART=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_RTC=y
 CONFIG_CMD_TIME=y
@@ -36,6 +37,7 @@ CONFIG_EFI_PARTITION=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_ADDR=0x800000001FBFE000
+CONFIG_TFTP_TSIZE=y
 CONFIG_CLK=y
 # CONFIG_INPUT is not set
 CONFIG_MISC=y
@@ -53,7 +55,12 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHYLIB=y
+CONFIG_PHY_MARVELL=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_ETH_PHY=y
 CONFIG_E1000=y
+CONFIG_NET_OCTEON=y
 CONFIG_PCI=y
 CONFIG_PCIE_OCTEON=y
 CONFIG_DM_REGULATOR=y
include/configs/octeon_ebb7304.h +2 -0
index 358db69a05b3..8c6c57bd546a 100644
@@ -16,4 +16,6 @@
 #define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
 #define CONFIG_SYS_FLASH_EMPTY_INFO	/* flinfo indicates empty blocks */
 
+#define PHY_ANEG_TIMEOUT	8000	/* PHY needs a longer aneg time */
+
 #endif /* __CONFIG_H__ */
Signature · 1 line
2.35.1
#49 lore raw

PATCH 52/52 mips: octeon: nic23: Enable ethernet support

In reply to Stefan Roese

This patch enables the Kconfig symbols needed for full ethernet support on the NIC23. Additionally board specific setup is done, mostly GPIOs related to SFP / GPIO configuration. With this, ethernet can be used on this board. Here an example of a tftp load:

=> tftp ffffffff81000000 big
Using ethernet-mac-nexus@11800e2000000 device
TFTP from server 192.168.1.5; our IP address is 192.168.1.247 Filename 'big'.
Load address: 0xffffffff81000000
Loading: ################################################## 10 MiB

         9.7 MiB/s

done
Bytes transferred = 10485760 (a00000 hex)

---
 board/Marvell/octeon_nic23/board.c | 87 +++++++++++++++++++++++++++++-
 configs/octeon_nic23_defconfig     | 10 +++-
 2 files changed, 95 insertions(+), 2 deletions(-)
board/Marvell/octeon_nic23/board.c +86 -1
index 9f5eb2e2a182..3e2c54444397 100644
@@ -1,10 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2021 Stefan Roese <[email protected]>
+ * Copyright (C) 2021-2022 Stefan Roese <[email protected]>
  */
 
 #include <dm.h>
 #include <ram.h>
+#include <asm/gpio.h>
 
 #include <mach/octeon_ddr.h>
 #include <mach/cvmx-qlm.h>
@@ -84,6 +85,52 @@ int board_fix_fdt(void *fdt)
 	return rc;
 }
 
+int board_early_init_f(void)
+{
+	struct gpio_desc gpio = {};
+	ofnode node;
+
+	/* Initial GPIO configuration */
+
+	/* GPIO 7: Vitesse reset */
+	node = ofnode_by_compatible(ofnode_null(), "vitesse,vsc7224");
+	if (ofnode_valid(node)) {
+		gpio_request_by_name_nodev(node, "los", 0, &gpio, GPIOD_IS_IN);
+		dm_gpio_free(gpio.dev, &gpio);
+		gpio_request_by_name_nodev(node, "reset", 0, &gpio,
+					   GPIOD_IS_OUT);
+		if (dm_gpio_is_valid(&gpio)) {
+			/* Vitesse reset */
+			debug("%s: Setting GPIO 7 to 1\n", __func__);
+			dm_gpio_set_value(&gpio, 1);
+		}
+		dm_gpio_free(gpio.dev, &gpio);
+	}
+
+	/* SFP+ transmitters */
+	ofnode_for_each_compatible_node(node, "ethernet,sfp-slot") {
+		gpio_request_by_name_nodev(node, "tx_disable", 0,
+					   &gpio, GPIOD_IS_OUT);
+		if (dm_gpio_is_valid(&gpio)) {
+			debug("%s: Setting GPIO %d to 1\n", __func__,
+			      gpio.offset);
+			dm_gpio_set_value(&gpio, 1);
+		}
+		dm_gpio_free(gpio.dev, &gpio);
+		gpio_request_by_name_nodev(node, "mod_abs", 0, &gpio,
+					   GPIOD_IS_IN);
+		dm_gpio_free(gpio.dev, &gpio);
+		gpio_request_by_name_nodev(node, "tx_error", 0, &gpio,
+					   GPIOD_IS_IN);
+		dm_gpio_free(gpio.dev, &gpio);
+		gpio_request_by_name_nodev(node, "rx_los", 0, &gpio,
+					   GPIOD_IS_IN);
+		dm_gpio_free(gpio.dev, &gpio);
+	}
+
+	return 0;
+}
+
 void board_configure_qlms(void)
 {
 	octeon_configure_qlm(4, 3000, CVMX_QLM_MODE_SATA_2X1, 0, 0, 0, 0);
@@ -100,7 +147,45 @@ void board_configure_qlms(void)
 
 int board_late_init(void)
 {
+	struct gpio_desc gpio = {};
+	ofnode node;
+
+	/* Turn on SFP+ transmitters */
+	ofnode_for_each_compatible_node(node, "ethernet,sfp-slot") {
+		gpio_request_by_name_nodev(node, "tx_disable", 0,
+					   &gpio, GPIOD_IS_OUT);
+		if (dm_gpio_is_valid(&gpio)) {
+			debug("%s: Setting GPIO %d to 0\n", __func__,
+			      gpio.offset);
+			dm_gpio_set_value(&gpio, 0);
+		}
+		dm_gpio_free(gpio.dev, &gpio);
+	}
+
 	board_configure_qlms();
 
 	return 0;
 }
+
+int last_stage_init(void)
+{
+	struct gpio_desc gpio = {};
+	ofnode node;
+
+	node = ofnode_by_compatible(ofnode_null(), "vitesse,vsc7224");
+	if (!ofnode_valid(node)) {
+		printf("Vitesse SPF DT node not found!");
+		return 0;
+	}
+
+	gpio_request_by_name_nodev(node, "reset", 0, &gpio, GPIOD_IS_OUT);
+	if (dm_gpio_is_valid(&gpio)) {
+		/* Take Vitesse retimer out of reset */
+		debug("%s: Setting GPIO 7 to 0\n", __func__);
+		dm_gpio_set_value(&gpio, 0);
+		mdelay(50);
+	}
+	dm_gpio_free(gpio.dev, &gpio);
+
+	return 0;
+}
configs/octeon_nic23_defconfig +9 -1
index 5427a9970a71..d44c650cef3c 100644
@@ -12,6 +12,7 @@ CONFIG_ARCH_OCTEON=y
 CONFIG_TARGET_OCTEON_NIC23=y
 # CONFIG_MIPS_CACHE_SETUP is not set
 # CONFIG_MIPS_CACHE_DISABLE is not set
+CONFIG_MIPS_RELOCATION_TABLE_SIZE=0xc000
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_OF_BOARD_FIXUP=y
@@ -19,7 +20,9 @@ CONFIG_SYS_LOAD_ADDR=0xffffffff80100000
 CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 # CONFIG_SYS_DEVICE_NULLDEV is not set
 CONFIG_ARCH_MISC_INIT=y
+CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_BOARD_LATE_INIT=y
+CONFIG_LAST_STAGE_INIT=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
@@ -37,6 +40,7 @@ CONFIG_CMD_FS_GENERIC=y
 CONFIG_EFI_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_ADDR=0xe000
+CONFIG_TFTP_TSIZE=y
 CONFIG_SATA=y
 CONFIG_AHCI_MVEBU=y
 CONFIG_CLK=y
@@ -50,7 +54,11 @@ CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
-# CONFIG_NETDEVICES is not set
+CONFIG_PHYLIB=y
+CONFIG_PHYLIB_10G=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_NET_OCTEON=y
 CONFIG_PCI=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
Signature · 1 line
2.35.1
#50 lore raw
In reply to Stefan Roese

Am Mittwoch, dem 30.03.2022 um 12:06 +0200 schrieb Stefan Roese:

Quoted 73 lines

This patchset adds the networking files and drivers including device helper headers and C files. Please excuse the massive amount of files in this patch series. Also the sometimes huge files (mostly headers with register definitions) that I needed to include.

The infrastructure code with all the headers is ported mistly without any intended functional changes from the 2013 Cavium / Marvell U-Boot version. It has undergone many hours of extensive code cleanup and reformatting. Some of it done by using tools (checkpatch, Lindent, clang
format etc) and also some of it done manually, as I couldn't find some
tools that could do the needed work in a reliable and functional way. The result is that checkpatch now only throws a "few" warnings that are
left. Some of those can't be removed without an even more extensive cleanup / rewrite of the code, like the addition of typedefs.

The added header, helper and infrastructure files in the first part of
the patch-series (patches 1-43) are the foundation, that is used by the
main Octeon U-Boot ethernet driver (patch 50/52). Patches 47-49 add the
DT nodes and properties to the corresponding dtsi / dts files. Patches
51 & 52 finally enable the ethernet support both MIPS Octeon boards, EBB7304 & NIC23.

All this is tested on the 2 Cavium / Marvell MIPS Octeon boards:
EBB7304 & NIC23

This patchset including the small Marvell PHY patches is available in this gitlab branch:

https://source.denx.de/u-boot/custodians/u-boot-marvell/-/tree/mips-octeon-ethernet-v1-2022-03-30

Thanks,
Stefan

Aaron Williams (40):
mips: octeon: Add misc cvmx-* header files
mips: octeon: Add cvmx-ilk-defs.h header file
mips: octeon: Add cvmx-iob-defs.h header file
mips: octeon: Add cvmx-lbk-defs.h header file
mips: octeon: Add cvmx-npei-defs.h header file
mips: octeon: Add cvmx-pcsxx-defs.h header file
mips: octeon: Add cvmx-xcv-defs.h header file
mips: octeon: Add cvmx-helper-agl.c
mips: octeon: Add cvmx-helper-bgx.c
mips: octeon: Add cvmx-helper-board.c
mips: octeon: Add cvmx-helper-fpa.c
mips: octeon: Add cvmx-helper-igl.c
mips: octeon: Add cvmx-helper-ipd.c
mips: octeon: Add cvmx-helper-loop.c
mips: octeon: Add cvmx-helper-npi.c
mips: octeon: Add cvmx-helper-pki.c
mips: octeon: Add cvmx-helper-pko.c
mips: octeon: Add cvmx-helper-pko3.c
mips: octeon: Add cvmx-helper-rgmii.c
mips: octeon: Add cvmx-helper-sgmii.c
mips: octeon: Add cvmx-helper-sfp.c
mips: octeon: Add cvmx-helper-xaui.c
mips: octeon: Add cvmx-agl.c
mips: octeon: Add cvmx-cmd-queue.c
mips: octeon: Add cvmx-fau-compat.c
mips: octeon: Add cvmx-fpa.c
mips: octeon: Add cvmx-fpa-resource.c
mips: octeon: Add cvmx-global-resource.c
mips: octeon: Add cvmx-ilk.c
mips: octeon: Add cvmx-ipd.c
mips: octeon: Add cvmx-pki.c
mips: octeon: Add cvmx-pki-resources.c

Quoted 8 lines

mips: octeon: Add cvmx-pko.c
mips: octeon: Add cvmx-pko3.c
mips: octeon: Add cvmx-pko3-queue.c
mips: octeon: Add cvmx-pko3-compat.c
mips: octeon: Add cvmx-pko3-resources.c
mips: octeon: Add cvmx-pko-internal-ports-range.c
mips: octeon: Add cvmx-qlm-tables.c
mips: octeon: Add cvmx-range.c

are those 10 millions helper functions really used by the ethernet driver? Do you really need features like SFP modules in U-Boot?

Maybe it helps to have a look at u-boot.map to see which functions are unused and are discarded by the linker. Those functions could be actually removed to reduce the LoC count ;)

Quoted 159 lines

Stefan Roese (12):
mips: octeon: Misc changes to existing headers for upcoming eth
support
mips: octeon: Misc changes to existing C files for upcoming eth
support
mips: octeon: Makefile: Enable building of the newly added C files
mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()
mips: octeon: cpu.c: Implement configure_lmtdma_window()
mips: octeon: octeon_common.h: Move init SP because of increased
image
size
mips: octeon: mrvl,cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
mips: octeon: mrvl,octeon-ebb7304.dts: Add ethernet DT support
mips: octeon: mrvl,octeon-nic23.dts: Add ethernet DT support
net: Add ethernet support for MIPS Octeon
mips: octeon: ebb7304: Enable ethernet support
mips: octeon: nic23: Enable ethernet support

 arch/mips/Kconfig                             |    1 +
 arch/mips/dts/mrvl,cn73xx.dtsi                |   35 +
 arch/mips/dts/mrvl,octeon-ebb7304.dts         |   45 +
 arch/mips/dts/mrvl,octeon-nic23.dts           |  238 ++
 arch/mips/mach-octeon/Makefile                |   35 +-
 arch/mips/mach-octeon/cpu.c                   |   47 +-
 arch/mips/mach-octeon/cvmx-agl.c              |  216 +
 arch/mips/mach-octeon/cvmx-bootmem.c          |    3 +-
 arch/mips/mach-octeon/cvmx-cmd-queue.c        |  449 +++
 arch/mips/mach-octeon/cvmx-fau-compat.c       |   53 +
 arch/mips/mach-octeon/cvmx-fpa-resource.c     |  305 ++
 arch/mips/mach-octeon/cvmx-fpa.c              | 1672 ++++++++
 arch/mips/mach-octeon/cvmx-global-resources.c |  639 +++
 arch/mips/mach-octeon/cvmx-helper-agl.c       |  231 ++
 arch/mips/mach-octeon/cvmx-helper-bgx.c       | 3215 +++++++++++++++
 arch/mips/mach-octeon/cvmx-helper-board.c     | 2030 ++++++++++
 arch/mips/mach-octeon/cvmx-helper-cfg.c       |   67 +-
 arch/mips/mach-octeon/cvmx-helper-fdt.c       |  645 ++-
 arch/mips/mach-octeon/cvmx-helper-fpa.c       |  329 ++
 arch/mips/mach-octeon/cvmx-helper-ilk.c       |  926 +++++
 arch/mips/mach-octeon/cvmx-helper-ipd.c       |  313 ++
 arch/mips/mach-octeon/cvmx-helper-loop.c      |  178 +
 arch/mips/mach-octeon/cvmx-helper-npi.c       |  146 +
 arch/mips/mach-octeon/cvmx-helper-pki.c       | 2156 ++++++++++
 arch/mips/mach-octeon/cvmx-helper-pko.c       |  312 ++
 arch/mips/mach-octeon/cvmx-helper-pko3.c      | 1252 ++++++
 arch/mips/mach-octeon/cvmx-helper-rgmii.c     |  431 ++
 arch/mips/mach-octeon/cvmx-helper-sfp.c       | 1877 +++++++++
 arch/mips/mach-octeon/cvmx-helper-sgmii.c     |  781 ++++
 arch/mips/mach-octeon/cvmx-helper-xaui.c      |  587 +++
 arch/mips/mach-octeon/cvmx-helper.c           |   45 +-
 arch/mips/mach-octeon/cvmx-ilk.c              | 1618 ++++++++
 arch/mips/mach-octeon/cvmx-ipd.c              |  690 ++++
 arch/mips/mach-octeon/cvmx-pki-resources.c    |  519 +++
 arch/mips/mach-octeon/cvmx-pki.c              | 1619 ++++++++
 .../cvmx-pko-internal-ports-range.c           |  164 +
 arch/mips/mach-octeon/cvmx-pko.c              | 1110 ++++++
 arch/mips/mach-octeon/cvmx-pko3-compat.c      |  656 +++
 arch/mips/mach-octeon/cvmx-pko3-queue.c       | 1331 ++++++
 arch/mips/mach-octeon/cvmx-pko3-resources.c   |  229 ++
 arch/mips/mach-octeon/cvmx-pko3.c             | 2143 ++++++++++
 arch/mips/mach-octeon/cvmx-qlm-tables.c       |  292 ++
 arch/mips/mach-octeon/cvmx-range.c            |  344 ++
 arch/mips/mach-octeon/include/mach/cvmx-agl.h |   45 +
 .../mach-octeon/include/mach/cvmx-bootmem.h   |    3 +-
 .../mach-octeon/include/mach/cvmx-config.h    |  128 +
 arch/mips/mach-octeon/include/mach/cvmx-fau.h |  581 +++
 arch/mips/mach-octeon/include/mach/cvmx-fpa.h |    3 +-
 .../mips/mach-octeon/include/mach/cvmx-fpa3.h |   37 -
 .../include/mach/cvmx-helper-board.h          |    6 +-
 .../include/mach/cvmx-helper-fdt.h            |   40 +-
 .../include/mach/cvmx-helper-pko.h            |    2 +-
 .../mach-octeon/include/mach/cvmx-helper.h    |   20 +
 .../mach-octeon/include/mach/cvmx-ilk-defs.h  | 2269 +++++++++++
 .../mach-octeon/include/mach/cvmx-iob-defs.h  | 1328 ++++++
 .../mach-octeon/include/mach/cvmx-lbk-defs.h  |  157 +
 .../mips/mach-octeon/include/mach/cvmx-mdio.h |  516 +++
 .../mach-octeon/include/mach/cvmx-npei-defs.h | 3550
+++++++++++++++++
 .../include/mach/cvmx-pcsxx-defs.h            |  787 ++++
 .../include/mach/cvmx-pki-cluster.h           |  343 ++
 arch/mips/mach-octeon/include/mach/cvmx-pko.h |  213 +
 .../include/mach/cvmx-pko3-resources.h        |   36 +
 .../mips/mach-octeon/include/mach/cvmx-pko3.h | 1052 +++++
 .../mach-octeon/include/mach/cvmx-range.h     |   23 +
 .../mips/mach-octeon/include/mach/cvmx-regs.h |  100 +-
 .../mach-octeon/include/mach/cvmx-xcv-defs.h  |  226 ++
 .../mach-octeon/include/mach/octeon_eth.h     |   54 +-
 board/Marvell/octeon_nic23/board.c            |   87 +-
 configs/octeon_ebb7304_defconfig              |    7 +
 configs/octeon_nic23_defconfig                |   10 +-
 drivers/net/Kconfig                           |    7 +
 drivers/net/Makefile                          |    1 +
 drivers/net/octeon/Makefile                   |    6 +
 drivers/net/octeon/octeon_eth.c               | 1060 +++++
 drivers/net/octeon/octeon_mdio.c              |  226 ++
 include/configs/octeon_common.h               |    2 +-
 include/configs/octeon_ebb7304.h              |    2 +
 77 files changed, 42315 insertions(+), 586 deletions(-)
 create mode 100644 arch/mips/mach-octeon/cvmx-agl.c
 create mode 100644 arch/mips/mach-octeon/cvmx-cmd-queue.c
 create mode 100644 arch/mips/mach-octeon/cvmx-fau-compat.c
 create mode 100644 arch/mips/mach-octeon/cvmx-fpa-resource.c
 create mode 100644 arch/mips/mach-octeon/cvmx-fpa.c
 create mode 100644 arch/mips/mach-octeon/cvmx-global-resources.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-agl.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-bgx.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-board.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-fpa.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-ilk.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-ipd.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-loop.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-npi.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-pki.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko3.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-rgmii.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-sfp.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-sgmii.c
 create mode 100644 arch/mips/mach-octeon/cvmx-helper-xaui.c
 create mode 100644 arch/mips/mach-octeon/cvmx-ilk.c
 create mode 100644 arch/mips/mach-octeon/cvmx-ipd.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pki-resources.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pki.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-
range.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-compat.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3-resources.c
 create mode 100644 arch/mips/mach-octeon/cvmx-pko3.c
 create mode 100644 arch/mips/mach-octeon/cvmx-qlm-tables.c
 create mode 100644 arch/mips/mach-octeon/cvmx-range.c
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-agl.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-config.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fau.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-ilk-
defs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-iob-
defs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-lbk-
defs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-mdio.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-npei-
defs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pcsxx-
defs.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pki-
cluster.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3-
resources.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-range.h
 create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-xcv-
defs.h
 create mode 100644 drivers/net/octeon/Makefile
 create mode 100644 drivers/net/octeon/octeon_eth.c
 create mode 100644 drivers/net/octeon/octeon_mdio.c
Signature · 1 line
- Daniel
#51 lore raw

Hi Daniel,

Quoted 83 lines · Daniel Schwierzeck

Am Mittwoch, dem 30.03.2022 um 12:06 +0200 schrieb Stefan Roese:

Quoted 73 lines

This patchset adds the networking files and drivers including device helper headers and C files. Please excuse the massive amount of files in this patch series. Also the sometimes huge files (mostly headers with register definitions) that I needed to include.

The infrastructure code with all the headers is ported mistly without any intended functional changes from the 2013 Cavium / Marvell U-Boot version. It has undergone many hours of extensive code cleanup and reformatting. Some of it done by using tools (checkpatch, Lindent, clang
format etc) and also some of it done manually, as I couldn't find some
tools that could do the needed work in a reliable and functional way. The result is that checkpatch now only throws a "few" warnings that are
left. Some of those can't be removed without an even more extensive cleanup / rewrite of the code, like the addition of typedefs.

The added header, helper and infrastructure files in the first part of
the patch-series (patches 1-43) are the foundation, that is used by the
main Octeon U-Boot ethernet driver (patch 50/52). Patches 47-49 add the
DT nodes and properties to the corresponding dtsi / dts files. Patches
51 & 52 finally enable the ethernet support both MIPS Octeon boards, EBB7304 & NIC23.

All this is tested on the 2 Cavium / Marvell MIPS Octeon boards:
EBB7304 & NIC23

This patchset including the small Marvell PHY patches is available in this gitlab branch:

https://source.denx.de/u-boot/custodians/u-boot-marvell/-/tree/mips-octeon-ethernet-v1-2022-03-30

Thanks,
Stefan

Aaron Williams (40):
mips: octeon: Add misc cvmx-* header files
mips: octeon: Add cvmx-ilk-defs.h header file
mips: octeon: Add cvmx-iob-defs.h header file
mips: octeon: Add cvmx-lbk-defs.h header file
mips: octeon: Add cvmx-npei-defs.h header file
mips: octeon: Add cvmx-pcsxx-defs.h header file
mips: octeon: Add cvmx-xcv-defs.h header file
mips: octeon: Add cvmx-helper-agl.c
mips: octeon: Add cvmx-helper-bgx.c
mips: octeon: Add cvmx-helper-board.c
mips: octeon: Add cvmx-helper-fpa.c
mips: octeon: Add cvmx-helper-igl.c
mips: octeon: Add cvmx-helper-ipd.c
mips: octeon: Add cvmx-helper-loop.c
mips: octeon: Add cvmx-helper-npi.c
mips: octeon: Add cvmx-helper-pki.c
mips: octeon: Add cvmx-helper-pko.c
mips: octeon: Add cvmx-helper-pko3.c
mips: octeon: Add cvmx-helper-rgmii.c
mips: octeon: Add cvmx-helper-sgmii.c
mips: octeon: Add cvmx-helper-sfp.c
mips: octeon: Add cvmx-helper-xaui.c
mips: octeon: Add cvmx-agl.c
mips: octeon: Add cvmx-cmd-queue.c
mips: octeon: Add cvmx-fau-compat.c
mips: octeon: Add cvmx-fpa.c
mips: octeon: Add cvmx-fpa-resource.c
mips: octeon: Add cvmx-global-resource.c
mips: octeon: Add cvmx-ilk.c
mips: octeon: Add cvmx-ipd.c
mips: octeon: Add cvmx-pki.c
mips: octeon: Add cvmx-pki-resources.c

Quoted 8 lines

mips: octeon: Add cvmx-pko.c
mips: octeon: Add cvmx-pko3.c
mips: octeon: Add cvmx-pko3-queue.c
mips: octeon: Add cvmx-pko3-compat.c
mips: octeon: Add cvmx-pko3-resources.c
mips: octeon: Add cvmx-pko-internal-ports-range.c
mips: octeon: Add cvmx-qlm-tables.c
mips: octeon: Add cvmx-range.c

Quoted 2 lines

are those 10 millions helper functions really used by the ethernet driver? Do you really need features like SFP modules in U-Boot?

It's very hard to add the network support for those SoCs with their quite complex devices and interfaces without using this proven code. I agree, that this is not really appealing. And at least the NIC23 only supports network via SFP modules, so there is not alterative interface here.

Quoted 3 lines

Maybe it helps to have a look at u-boot.map to see which functions are unused and are discarded by the linker. Those functions could be actually removed to reduce the LoC count ;)

Good idea, thanks. I was looking for something like this, but never got the idea to actually look at the u-boot.map file to detect the unused functions, so that I can remove them. I'll work on this to get the LoC down a bit. ;)

Thanks,
Stefan

Quoted 151 lines
Quoted 151 lines

Stefan Roese (12):
mips: octeon: Misc changes to existing headers for upcoming eth
support
mips: octeon: Misc changes to existing C files for upcoming eth
support
mips: octeon: Makefile: Enable building of the newly added C files
mips: octeon: cpu.c: Move bootmem init to arch_early_init_r()
mips: octeon: cpu.c: Implement configure_lmtdma_window()
mips: octeon: octeon_common.h: Move init SP because of increased
image
size
mips: octeon: mrvl,cn73xx.dtsi: Add ethernet (BGX) and SMI DT nodes
mips: octeon: mrvl,octeon-ebb7304.dts: Add ethernet DT support
mips: octeon: mrvl,octeon-nic23.dts: Add ethernet DT support
net: Add ethernet support for MIPS Octeon
mips: octeon: ebb7304: Enable ethernet support
mips: octeon: nic23: Enable ethernet support

  arch/mips/Kconfig                             |    1 +
  arch/mips/dts/mrvl,cn73xx.dtsi                |   35 +
  arch/mips/dts/mrvl,octeon-ebb7304.dts         |   45 +
  arch/mips/dts/mrvl,octeon-nic23.dts           |  238 ++
  arch/mips/mach-octeon/Makefile                |   35 +-
  arch/mips/mach-octeon/cpu.c                   |   47 +-
  arch/mips/mach-octeon/cvmx-agl.c              |  216 +
  arch/mips/mach-octeon/cvmx-bootmem.c          |    3 +-
  arch/mips/mach-octeon/cvmx-cmd-queue.c        |  449 +++
  arch/mips/mach-octeon/cvmx-fau-compat.c       |   53 +
  arch/mips/mach-octeon/cvmx-fpa-resource.c     |  305 ++
  arch/mips/mach-octeon/cvmx-fpa.c              | 1672 ++++++++
  arch/mips/mach-octeon/cvmx-global-resources.c |  639 +++
  arch/mips/mach-octeon/cvmx-helper-agl.c       |  231 ++
  arch/mips/mach-octeon/cvmx-helper-bgx.c       | 3215 +++++++++++++++
  arch/mips/mach-octeon/cvmx-helper-board.c     | 2030 ++++++++++
  arch/mips/mach-octeon/cvmx-helper-cfg.c       |   67 +-
  arch/mips/mach-octeon/cvmx-helper-fdt.c       |  645 ++-
  arch/mips/mach-octeon/cvmx-helper-fpa.c       |  329 ++
  arch/mips/mach-octeon/cvmx-helper-ilk.c       |  926 +++++
  arch/mips/mach-octeon/cvmx-helper-ipd.c       |  313 ++
  arch/mips/mach-octeon/cvmx-helper-loop.c      |  178 +
  arch/mips/mach-octeon/cvmx-helper-npi.c       |  146 +
  arch/mips/mach-octeon/cvmx-helper-pki.c       | 2156 ++++++++++
  arch/mips/mach-octeon/cvmx-helper-pko.c       |  312 ++
  arch/mips/mach-octeon/cvmx-helper-pko3.c      | 1252 ++++++
  arch/mips/mach-octeon/cvmx-helper-rgmii.c     |  431 ++
  arch/mips/mach-octeon/cvmx-helper-sfp.c       | 1877 +++++++++
  arch/mips/mach-octeon/cvmx-helper-sgmii.c     |  781 ++++
  arch/mips/mach-octeon/cvmx-helper-xaui.c      |  587 +++
  arch/mips/mach-octeon/cvmx-helper.c           |   45 +-
  arch/mips/mach-octeon/cvmx-ilk.c              | 1618 ++++++++
  arch/mips/mach-octeon/cvmx-ipd.c              |  690 ++++
  arch/mips/mach-octeon/cvmx-pki-resources.c    |  519 +++
  arch/mips/mach-octeon/cvmx-pki.c              | 1619 ++++++++
  .../cvmx-pko-internal-ports-range.c           |  164 +
  arch/mips/mach-octeon/cvmx-pko.c              | 1110 ++++++
  arch/mips/mach-octeon/cvmx-pko3-compat.c      |  656 +++
  arch/mips/mach-octeon/cvmx-pko3-queue.c       | 1331 ++++++
  arch/mips/mach-octeon/cvmx-pko3-resources.c   |  229 ++
  arch/mips/mach-octeon/cvmx-pko3.c             | 2143 ++++++++++
  arch/mips/mach-octeon/cvmx-qlm-tables.c       |  292 ++
  arch/mips/mach-octeon/cvmx-range.c            |  344 ++
  arch/mips/mach-octeon/include/mach/cvmx-agl.h |   45 +
  .../mach-octeon/include/mach/cvmx-bootmem.h   |    3 +-
  .../mach-octeon/include/mach/cvmx-config.h    |  128 +
  arch/mips/mach-octeon/include/mach/cvmx-fau.h |  581 +++
  arch/mips/mach-octeon/include/mach/cvmx-fpa.h |    3 +-
  .../mips/mach-octeon/include/mach/cvmx-fpa3.h |   37 -
  .../include/mach/cvmx-helper-board.h          |    6 +-
  .../include/mach/cvmx-helper-fdt.h            |   40 +-
  .../include/mach/cvmx-helper-pko.h            |    2 +-
  .../mach-octeon/include/mach/cvmx-helper.h    |   20 +
  .../mach-octeon/include/mach/cvmx-ilk-defs.h  | 2269 +++++++++++
  .../mach-octeon/include/mach/cvmx-iob-defs.h  | 1328 ++++++
  .../mach-octeon/include/mach/cvmx-lbk-defs.h  |  157 +
  .../mips/mach-octeon/include/mach/cvmx-mdio.h |  516 +++
  .../mach-octeon/include/mach/cvmx-npei-defs.h | 3550
+++++++++++++++++
  .../include/mach/cvmx-pcsxx-defs.h            |  787 ++++
  .../include/mach/cvmx-pki-cluster.h           |  343 ++
  arch/mips/mach-octeon/include/mach/cvmx-pko.h |  213 +
  .../include/mach/cvmx-pko3-resources.h        |   36 +
  .../mips/mach-octeon/include/mach/cvmx-pko3.h | 1052 +++++
  .../mach-octeon/include/mach/cvmx-range.h     |   23 +
  .../mips/mach-octeon/include/mach/cvmx-regs.h |  100 +-
  .../mach-octeon/include/mach/cvmx-xcv-defs.h  |  226 ++
  .../mach-octeon/include/mach/octeon_eth.h     |   54 +-
  board/Marvell/octeon_nic23/board.c            |   87 +-
  configs/octeon_ebb7304_defconfig              |    7 +
  configs/octeon_nic23_defconfig                |   10 +-
  drivers/net/Kconfig                           |    7 +
  drivers/net/Makefile                          |    1 +
  drivers/net/octeon/Makefile                   |    6 +
  drivers/net/octeon/octeon_eth.c               | 1060 +++++
  drivers/net/octeon/octeon_mdio.c              |  226 ++
  include/configs/octeon_common.h               |    2 +-
  include/configs/octeon_ebb7304.h              |    2 +
  77 files changed, 42315 insertions(+), 586 deletions(-)

create mode 100644 arch/mips/mach-octeon/cvmx-agl.c create mode 100644 arch/mips/mach-octeon/cvmx-cmd-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-fau-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa-resource.c create mode 100644 arch/mips/mach-octeon/cvmx-fpa.c create mode 100644 arch/mips/mach-octeon/cvmx-global-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-agl.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-bgx.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-board.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-fpa.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ilk.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-ipd.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-loop.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-npi.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pki.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-pko3.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-rgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sfp.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-sgmii.c create mode 100644 arch/mips/mach-octeon/cvmx-helper-xaui.c create mode 100644 arch/mips/mach-octeon/cvmx-ilk.c create mode 100644 arch/mips/mach-octeon/cvmx-ipd.c create mode 100644 arch/mips/mach-octeon/cvmx-pki-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pki.c create mode 100644 arch/mips/mach-octeon/cvmx-pko-internal-ports-
range.c
create mode 100644 arch/mips/mach-octeon/cvmx-pko.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-compat.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-queue.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3-resources.c create mode 100644 arch/mips/mach-octeon/cvmx-pko3.c create mode 100644 arch/mips/mach-octeon/cvmx-qlm-tables.c create mode 100644 arch/mips/mach-octeon/cvmx-range.c create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-agl.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-config.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-fau.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-ilk-
defs.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-iob-
defs.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-lbk-
defs.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-mdio.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-npei-
defs.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pcsxx-
defs.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pki-
cluster.h
create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3-
resources.h

Quoted 8 lines
Quoted 8 lines

create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-pko3.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-range.h create mode 100644 arch/mips/mach-octeon/include/mach/cvmx-xcv-
defs.h
create mode 100644 drivers/net/octeon/Makefile
create mode 100644 drivers/net/octeon/octeon_eth.c create mode 100644 drivers/net/octeon/octeon_mdio.c

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]