From 1620ee2ca3efb0faba8f6cd182c0fa3bd9b79e62 Mon Sep 17 00:00:00 2001 From: "Waksman, Michael" <michael.waksman@intel.com> Date: Sun, 11 Mar 2018 11:56:15 +0100 Subject: [PATCH] Merge pull request #260 in SW_PON/linux from FALCONSW-681-resolve-klocwork-critical-and-error-on-ppv4-qos-driver to xrx500 Resolve Klocwork criticals and errors on ppv4 qos * commit '99018c059026049863975232f093960feb54597f': Resolve Klocwork criticals and errors --- drivers/net/ethernet/lantiq/ppv4/qos/Makefile | 4 +- .../ethernet/lantiq/ppv4/qos/pp_qos_debugfs.c | 17 +- .../net/ethernet/lantiq/ppv4/qos/pp_qos_fw.c | 60 +- .../net/ethernet/lantiq/ppv4/qos/pp_qos_fw.h | 5 + .../ethernet/lantiq/ppv4/qos/pp_qos_main.c | 112 +- .../ethernet/lantiq/ppv4/qos/pp_qos_tests.c | 2574 ----------------- .../ethernet/lantiq/ppv4/qos/pp_qos_utils.c | 122 +- .../ethernet/lantiq/ppv4/qos/pp_qos_utils.h | 5 +- include/net/pp_qos_drv.h | 4 +- 9 files changed, 231 insertions(+), 2672 deletions(-) delete mode 100644 drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_tests.c diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/Makefile b/drivers/net/ethernet/lantiq/ppv4/qos/Makefile index 4241e0562..c461b727d 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/Makefile +++ b/drivers/net/ethernet/lantiq/ppv4/qos/Makefile @@ -3,7 +3,5 @@ # obj-$(CONFIG_LTQ_PPV4_QOS) += pp_qos_drv.o -pp_qos_drv-y := pp_qos_linux.o pp_qos_main.o pp_qos_utils.o pp_qos_fw.o pp_qos_tests.o pp_qos_debugfs.o +pp_qos_drv-y := pp_qos_linux.o pp_qos_main.o pp_qos_utils.o pp_qos_fw.o pp_qos_debugfs.o ccflags-y += -Iinclude/net -DQOS_CPU_UC_SAME_ENDIANESS - -ccflags-$(CONFIG_LTQ_PPV4_QOS_TEST) += -DPP_QOS_TEST diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_debugfs.c b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_debugfs.c index 1e93e73ae..0683fe7ea 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_debugfs.c +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_debugfs.c @@ -54,15 +54,15 @@ static int pp_qos_dbg_node_show(struct seq_file *s, void *unused) "Unknown"}; static const char *const yesno[] = {"No", "Yes"}; int rc; - struct pp_qos_node_info info; + struct pp_qos_node_info info = {0, }; pdev = s->private; dev_info(&pdev->dev, "node_show called\n"); if (pdev) { pdata = platform_get_drvdata(pdev); qdev = pdata->qdev; - if (!qdev->initialized) { - seq_puts(s, "Device is not initialized !!!!\n"); + if (!qos_device_ready(qdev)) { + seq_puts(s, "Device is not ready !!!!\n"); return 0; } @@ -152,8 +152,8 @@ static int pp_qos_dbg_stat_show(struct seq_file *s, void *unused) if (pdev) { pdata = platform_get_drvdata(pdev); qdev = pdata->qdev; - if (!qdev->initialized) { - seq_puts(s, "Device is not initialized !!!!\n"); + if (!qos_device_ready(qdev)) { + seq_puts(s, "Device is not ready !!!!\n"); return 0; } @@ -249,7 +249,7 @@ static int pp_qos_dbg_gen_show(struct seq_file *s, void *unused) if (pdev) { pdata = platform_get_drvdata(pdev); qdev = pdata->qdev; - if (qdev->initialized) { + if (qos_device_ready(qdev)) { ports = 0; scheds = 0; queues = 0; @@ -285,7 +285,7 @@ static int pp_qos_dbg_gen_show(struct seq_file *s, void *unused) seq_printf(s, "Used nodes:\t%u\nPorts:\t\t%u\nScheds:\t\t%u\nQueues:\t\t%u\nInternals:\t%u\n", used, ports, scheds, queues, internals); } else { - seq_puts(s, "Device is not initialized !!!!\n"); + seq_puts(s, "Device is not ready !!!!\n"); } } else { @@ -448,13 +448,12 @@ static int ctrl_set(void *data, u64 val) QOS_LOG_INFO("running info test\n"); info_test(); break; - +#endif case 14: QOS_LOG_INFO("printing logger\n"); print_fw_log(pdev); break; -#endif default: QOS_LOG_INFO("unknown test\n"); diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.c b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.c index 4c4b849b3..739ae8e6c 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.c +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.c @@ -65,7 +65,8 @@ OP(CMD_TYPE_PUSH_DESC) \ OP(CMD_TYPE_GET_NODE_INFO) \ OP(CMD_TYPE_REMOVE_SHARED_GROUP) \ - OP(CMD_TYPE_SET_SHARED_GROUP) + OP(CMD_TYPE_SET_SHARED_GROUP) \ + OP(CMD_TYPE_GET_NUM_USED_NODES) enum cmd_type { FW_CMDS(GEN_ENUM) @@ -381,6 +382,12 @@ struct cmd_remove_shared_group { unsigned int id; }; +struct cmd_get_num_used_nodes { + struct cmd base; + unsigned int addr; + uint32_t *num; +}; + union driver_cmd { struct cmd cmd; struct stub_cmd stub; @@ -402,6 +409,7 @@ union driver_cmd { struct cmd_remove_shared_group remove_shared_group; struct cmd_push_desc pushd; struct cmd_get_node_info node_info; + struct cmd_get_num_used_nodes num_used; }; /******************************************************************************/ @@ -938,6 +946,32 @@ void create_get_node_info_cmd( qdev->drvcmds.cmd_fw_id++; } +void create_num_used_nodes_cmd( + struct pp_qos_dev *qdev, + unsigned int addr, + uint32_t *num) +{ + struct cmd_get_num_used_nodes cmd; + + if (PP_QOS_DEVICE_IS_ASSERT(qdev)) + return; + + memset(&cmd, 0, sizeof(cmd)); + cmd_init( + qdev, + &(cmd.base), + CMD_TYPE_GET_NODE_INFO, + sizeof(cmd), + CMD_FLAGS_POST_PROCESS); + cmd.addr = addr; + cmd.num = num; + QOS_LOG_INFO("cmd %u:%u CMD_TYPE_GET_NUM_USED_NODES\n", + qdev->drvcmds.cmd_id, + qdev->drvcmds.cmd_fw_id); + cmd_queue_put(qdev->drvcmds.cmdq, &cmd, sizeof(cmd)); + qdev->drvcmds.cmd_fw_id++; +} + static void _create_set_shared_group_cmd(struct pp_qos_dev *qdev, enum cmd_type ctype, unsigned int id, @@ -1447,6 +1481,21 @@ static uint32_t *fw_write_get_port_stats( return buf; } +static uint32_t *fw_write_get_num_used_nodes( + uint32_t *buf, + const struct cmd_get_num_used_nodes *cmd, + uint32_t flags) +{ +/* Use when firmware implement this command */ +#if 0 + *buf++ = qos_u32_to_uc(UC_QOS_COMMAND_GET_NUM_USED_NODES); + *buf++ = qos_u32_to_uc(flags); + *buf++ = qos_u32_to_uc(1); + *buf++ = qos_u32_to_uc((uintptr_t)cmd->addr & 0xFFFFFFFF); +#endif + return buf; +} + static uint32_t *fw_write_set_shared_group( uint32_t *buf, enum cmd_type ctype, @@ -2032,6 +2081,10 @@ static void post_process(struct pp_qos_dev *qdev, union driver_cmd *dcmd) pstat->total_yellow_bytes = fw_pstat->total_yellow_bytes; break; + case CMD_TYPE_GET_NUM_USED_NODES: + *(dcmd->num_used.num) = *((uint32_t *)(qdev->stat)); + break; + case CMD_TYPE_GET_NODE_INFO: post_process_get_node_info(qdev, &dcmd->node_info); break; @@ -2319,6 +2372,11 @@ void enqueue_cmds(struct pp_qos_dev *qdev) prev, &dcmd.port_stats, flags); break; + case CMD_TYPE_GET_NUM_USED_NODES: + cur = fw_write_get_num_used_nodes( + prev, &dcmd.num_used, flags); + break; + case CMD_TYPE_ADD_SHARED_GROUP: case CMD_TYPE_SET_SHARED_GROUP: cur = fw_write_set_shared_group( diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.h b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.h index df51fdde4..3ad07c28a 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.h +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_fw.h @@ -101,6 +101,9 @@ int do_load_firmware( void *data); void signal_uc(struct pp_qos_dev *qdev); +void create_num_used_nodes_cmd(struct pp_qos_dev *qdev, + unsigned int addr, + uint32_t *num); #elif defined(PRINT_CREATE_CMD) #define create_move_cmd(qdev, dst, src, dst_port)\ QOS_LOG_DEBUG("MOVE: %u ==> %u\n", src, dst) @@ -130,6 +133,7 @@ void signal_uc(struct pp_qos_dev *qdev); #define create_get_port_stats_cmd(qdev, phy, addr, pstat) #define create_get_node_info_cmd(qdev, phy, addr, info) #define create_push_desc_cmd(qdev, queue, size, color, addr) +#define create_num_used_nodes_cmd(qdev, addr, num) #else #define create_move_cmd(qdev, dst, src, dst_port) #define create_set_port_cmd(qdev, conf, phy, modified) @@ -152,5 +156,6 @@ void signal_uc(struct pp_qos_dev *qdev); #define create_get_port_stats_cmd(qdev, phy, addr, pstat) #define create_get_node_info_cmd(qdev, phy, addr, info) #define create_push_desc_cmd(qdev, queue, size, color, addr) +#define create_num_used_nodes_cmd(qdev, addr, num) #endif #endif diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_main.c b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_main.c index 23383b59d..c6b10937d 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_main.c +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_main.c @@ -158,8 +158,7 @@ int pp_qos_port_allocate( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -170,7 +169,7 @@ int pp_qos_port_allocate( rc = -EBUSY; goto out; } - } else if (!QOS_PHY_VALID(physical_id) || + } else if (physical_id >= QOS_MAX_PORTS || !qdev->reserved_ports[physical_id]) { QOS_LOG( "requested physical id %u is not reserved or out of range\n", @@ -206,8 +205,7 @@ int pp_qos_port_suspend(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -232,8 +230,7 @@ int pp_qos_port_resume(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -258,8 +255,7 @@ int pp_qos_port_block(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -287,8 +283,7 @@ int pp_qos_port_unblock(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -316,8 +311,7 @@ int pp_qos_port_flush(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -342,8 +336,7 @@ int pp_qos_port_remove(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -397,8 +390,7 @@ int pp_qos_port_conf_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -422,8 +414,7 @@ int pp_qos_port_info_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -462,8 +453,7 @@ int pp_qos_port_get_queues( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -543,8 +533,7 @@ int pp_qos_port_set( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -575,8 +564,7 @@ int pp_qos_port_stat_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -856,8 +844,7 @@ int pp_qos_queue_allocate(struct pp_qos_dev *qdev, unsigned int *id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -924,8 +911,7 @@ int pp_qos_queue_conf_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -967,8 +953,7 @@ int pp_qos_queue_remove(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1082,8 +1067,7 @@ int pp_qos_queue_set( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1121,8 +1105,7 @@ int pp_qos_queue_suspend(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1160,8 +1143,7 @@ int pp_qos_queue_resume(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1200,8 +1182,7 @@ int pp_qos_queue_block(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1239,8 +1220,7 @@ int pp_qos_queue_unblock(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1276,8 +1256,7 @@ int pp_qos_queue_flush(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1306,8 +1285,7 @@ int pp_qos_queue_info_get(struct pp_qos_dev *qdev, unsigned int id, QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1352,8 +1330,7 @@ int pp_qos_queue_stat_get(struct pp_qos_dev *qdev, unsigned int id, QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1490,8 +1467,7 @@ int pp_qos_sched_allocate(struct pp_qos_dev *qdev, unsigned int *id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1512,8 +1488,7 @@ int pp_qos_sched_remove(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1626,8 +1601,7 @@ int pp_qos_sched_set( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1670,8 +1644,7 @@ int pp_qos_sched_conf_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1690,8 +1663,7 @@ int pp_qos_sched_suspend(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1716,8 +1688,7 @@ int pp_qos_sched_resume(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1745,8 +1716,7 @@ int pp_qos_sched_info_get( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1785,8 +1755,7 @@ int pp_qos_sched_get_queues(struct pp_qos_dev *qdev, unsigned int id, QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1817,8 +1786,7 @@ int pp_qos_get_fw_version( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1845,8 +1813,7 @@ int pp_qos_get_node_info( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1894,8 +1861,7 @@ int pp_qos_shared_limit_group_add( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -1933,8 +1899,7 @@ int pp_qos_shared_limit_group_remove(struct pp_qos_dev *qdev, unsigned int id) QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -2032,8 +1997,7 @@ int pp_qos_shared_limit_group_get_members( QOS_LOCK(qdev); PP_QOS_ENTER_FUNC(); - if (!qdev->initialized) { - QOS_LOG_ERR("Device was not initialized\n"); + if (!qos_device_ready(qdev)) { rc = -EINVAL; goto out; } @@ -2077,7 +2041,7 @@ int pp_qos_dev_init(struct pp_qos_dev *qdev, struct pp_qos_init_param *conf) qdev->reserved_ports, qdev->max_port, conf->reserved_ports, - MAX_PORTS); + QOS_MAX_PORTS); qdev->hwconf.wred_total_avail_resources = conf->wred_total_avail_resources; diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_tests.c b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_tests.c deleted file mode 100644 index d4fe2a643..000000000 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_tests.c +++ /dev/null @@ -1,2574 +0,0 @@ -#ifdef PP_QOS_TEST -#include "pp_qos_fw.h" -#include "pp_qos_utils.h" - -#define QOS_INVALID_PRIORITY 0xF - -/* - * Check following for each octet: - * Number of nodes marked as used on each octet matches octet usage - * Ports' octets are not enqueued - * Non ports' octets are enqueued on a list which match their usage count - * No unused node interleaves sequence of used nodes - * - */ -static void check_octets(struct pp_qos_dev *qdev) -{ - int i; - int j; - int unused_seen; - uint8_t usage; - int last; - struct qos_node *node; - - last = octet_of_phy(qdev->max_port); - - for (i = 0; i < NUM_OF_OCTETS; ++i) { - node = get_node_from_phy(qdev->nodes, 8 * i); - usage = 0; - unused_seen = 0; - for (j = 0; j < 8; ++j) { - if (node_used(node)) { - if (i > last) - QOS_ASSERT(!unused_seen, "Node %u is used after previous node in same octet was unused\n", i * 8 + j); - usage++; - } else { - unused_seen = 1; - } - node++; - } - debug_verify_octet_usage(qdev->octets, i, usage); - } -} - -/* - * Check the following for each id: - * If id is mapped to a valid phy - * - Node designated by this phy is marked as used - * - The inverse mapping from phy maps to the same id - * - * Check the following for each phy: - * If phy designates a used node - * - It is mapped to valid id - * - The inverse mapping from id maps to the same phy - * - */ -static void check_mapping(struct pp_qos_dev *qdev) -{ - uint16_t phy; - uint16_t id; - struct qos_node *node; - unsigned i; - - for (i = 0; i < NUM_OF_NODES; ++i) { - phy = get_phy_from_id(qdev->mapping, i); - if (QOS_PHY_VALID(phy)) { - node = get_node_from_phy(qdev->nodes, phy); - QOS_ASSERT( - node_used(node), - "Id %u is mapped to unused node %u\n", i, phy); - id = get_id_from_phy(qdev->mapping, phy); - QOS_ASSERT( - id == i, - "Id %u is mapped to phy %u, but the latter is mapped to %u\n", i, phy, id); - } - - node = get_node_from_phy(qdev->nodes, i); - id = get_id_from_phy(qdev->mapping, i); - QOS_ASSERT(!node_used(node) || QOS_ID_VALID(id), "Node %u is used but has invalid id\n", i); - if (QOS_ID_VALID(id)) { - phy = get_phy_from_id(qdev->mapping, id); - QOS_ASSERT( - phy == i, - "Phy %u is mapped to id %u, but the latter is mapped to %u\n", i, id, phy); - } - } -} - -struct pp_pool { - int capacity; - int top; - uint16_t invalid; - uint16_t data[1]; -}; -static uint8_t ids[NUM_OF_NODES]; -static uint8_t rlms[NUM_OF_QUEUES]; -static void check_resources_usage(struct pp_qos_dev *qdev) -{ - int i; - int id; - int rlm; - struct qos_node *node; - memset(ids, 0, NUM_OF_NODES); - memset(rlms, 0, NUM_OF_QUEUES); - - node = get_node_from_phy(qdev->nodes, 0); - for (i = 0; i < NUM_OF_NODES; ++i) { - if (node_used(node)) { - id = get_id_from_phy(qdev->mapping, i); - QOS_ASSERT(ids[id] == 0, "Id %d of phy %d already found\n", id ,i); - ids[id] = 1; - if (node->type == TYPE_QUEUE) { - rlm = node->data.queue.rlm; - QOS_ASSERT(rlms[rlm] == 0, "Rlm %d of phy %d already found\n", rlm ,i); - rlms[rlm] = 1; - } - } - - if (qdev->ids->top > i) { - id = qdev->ids->data[i]; - QOS_ASSERT(ids[id] == 0, "Id %d on free ids pool already found\n", id); - ids[id] = 1; - } - - if (qdev->rlms->top > i) { - rlm = qdev->rlms->data[i]; - QOS_ASSERT(rlms[rlm] == 0, "Rlm %d on free rlms pool already found\n", rlm); - rlms[rlm] = 1; - } - - ++node; - } - - for (i = 0; i < NUM_OF_NODES; ++i) { - QOS_ASSERT(ids[i], "Id %d was not found\n", i); - QOS_ASSERT(i >= NUM_OF_QUEUES || rlms[i], "Rlm %d was not found\n", i); - } -} - - - /* - * Check following tests for each node: - * If node is a parent - * - All the nodes it claims are its children, are indeed children and have it as their - * parent - * - If its a WSP parent then its children are ordered correctly - * - The sum of share of its children does not exceed 100 - * - * If node is a child - * - It is indeed recognized by its claimed parent as a child - * - */ -static void check_parent_children(struct pp_qos_dev *qdev) -{ - int phy; - int i; - int check_priorities; - int priority; - struct qos_node *node; - struct qos_node *cur; - int first_child_phy; - int last_child_phy; - int share; - - for (phy = 0; phy < NUM_OF_NODES; ++phy) { - node = get_node_from_phy(qdev->nodes, phy); - if (node_parent(node)) { - i = node->parent_prop.num_of_children; - QOS_ASSERT(i >= 0, "Illegal number of children %d for node %d\n", i, phy); - check_priorities = (node->parent_prop.arbitration == PP_QOS_ARBITRATION_WSP); - priority = -1; - if (i) - cur = get_node_from_phy(qdev->nodes, node->parent_prop.first_child_phy); - for (; i > 0; --i) { - QOS_ASSERT(node_child(cur), - "Node %u claims that %u is its child but the latter is not a child (or marked unused)\n", phy, get_phy_from_node(qdev->nodes, cur)); - QOS_ASSERT(cur->child_prop.parent_phy == phy, - "Node %d has node %u as a child, but the latter has node %u as its parent\n", - phy, get_phy_from_node(qdev->nodes, cur), cur->child_prop.parent_phy) ; - QOS_ASSERT( - !check_priorities || (cur->child_prop.priority > priority), - "Child %u of wsp parent %u has priority %u while previous child priority is %u\n", - get_phy_from_node(qdev->nodes, cur), phy, cur->child_prop.priority, priority); - - if (check_priorities) - priority = cur->child_prop.priority; - - ++cur; - } - - //share = get_virt_children_bandwidth_share(qdev, node); - share = get_children_bandwidth_share(qdev, node); - QOS_ASSERT(share <= 100, "Bandwidth share of %d children is %d\n", phy, share); - if (node_internal(node)) { - share = get_children_bandwidth_share(qdev, node); - QOS_ASSERT(share == node->child_prop.virt_bw_share, "iInternal scheduler: sum bandwidth children is %d while parent is %d\n", share, node->child_prop.virt_bw_share); - } - } - - if (node_child(node)) { - cur = get_node_from_phy(qdev->nodes, node->child_prop.parent_phy); - QOS_ASSERT(node_parent(cur), "Node %u claims that %u is its parent, but the latter is not a parent (or marked unused)\n", phy, get_phy_from_node(qdev->nodes, cur)); - first_child_phy = cur->parent_prop.first_child_phy; - last_child_phy = first_child_phy + cur->parent_prop.num_of_children - 1; - QOS_ASSERT((phy >= first_child_phy) && (phy <= last_child_phy), - "Node %d has node %u as a parent, but the latter children are %u..%u\n", - phy, get_phy_from_node(qdev->nodes, cur), first_child_phy, last_child_phy); - } - ++node; - } -} - -static void check_consistency(struct pp_qos_dev *qdev) -{ - QOS_ASSERT(!QOS_SPIN_IS_LOCKED(qdev), "Lock is taken\n"); - check_octets(qdev); - check_parent_children(qdev); - check_mapping(qdev); -} - -static void check_consistency_with_resources(struct pp_qos_dev *qdev) -{ - check_consistency(qdev); - check_resources_usage(qdev); -} - -static void create_nodes(struct pp_qos_dev *qdev, uint16_t start_phy, int count) -{ - int i; - uint16_t id; - struct qos_node *node; - - nodes_modify_used_status(qdev, start_phy, count, 1); - node = get_node_from_phy(qdev->nodes, start_phy); - for (i = start_phy; i < start_phy + count; ++i) { - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, i); - node->type = TYPE_UNKNOWN; - ++node; - } -} - -static void destroy_nodes(struct pp_qos_dev *qdev, uint16_t start_phy, int count) -{ - int i; - uint16_t id; - - nodes_modify_used_status(qdev, start_phy, count, 0); - - for (i = start_phy; i < start_phy + count; ++i) { - id = get_id_from_phy(qdev->mapping, i); - map_invalidate_id(qdev->mapping, id); - pp_pool_put(qdev->ids, id); - } -} - -static void config_parent_node(struct pp_qos_dev *qdev, uint16_t phy, enum node_type type, enum pp_qos_arbitration arb, uint16_t first_child, int num) -{ - struct qos_node *node; - - node = get_node_from_phy(qdev->nodes, phy); - node->type = type; - node->parent_prop.arbitration = arb; - node->parent_prop.first_child_phy = first_child; - node->parent_prop.num_of_children = num; -} - -static void config_child_node(struct pp_qos_dev *qdev, uint16_t phy, enum node_type type, uint16_t parent_phy, int priority) -{ - struct qos_node *node; - - node = get_node_from_phy(qdev->nodes, phy); - node->type = type; - - if (QOS_PHY_VALID(parent_phy)) - node->child_prop.parent_phy =parent_phy; - - if (priority != QOS_INVALID_PRIORITY) - node->child_prop.priority = priority; -} - -/* - */ -static void test_modify_used_status(struct pp_qos_dev *qdev) -{ - debug_verify_octet_usage(qdev->octets, 2, 0); - debug_verify_octet_usage(qdev->octets, 3, 0); - debug_verify_octet_usage(qdev->octets, 4, 0); - - create_nodes(qdev, 18, 15); - debug_verify_octet_usage(qdev->octets, 2, 6); - debug_verify_octet_usage(qdev->octets, 3, 8); - debug_verify_octet_usage(qdev->octets, 4, 1); - - destroy_nodes(qdev, 25, 2); - debug_verify_octet_usage(qdev->octets, 2, 6); - debug_verify_octet_usage(qdev->octets, 3, 6); - debug_verify_octet_usage(qdev->octets, 4, 1); - - destroy_nodes(qdev, 18, 7); - debug_verify_octet_usage(qdev->octets, 2, 0); - debug_verify_octet_usage(qdev->octets, 3, 5); - debug_verify_octet_usage(qdev->octets, 4, 1); - - destroy_nodes(qdev, 27, 6); - debug_verify_octet_usage(qdev->octets, 2, 0); - debug_verify_octet_usage(qdev->octets, 3, 0); - debug_verify_octet_usage(qdev->octets, 4, 0); - check_consistency(qdev); -} - -static void test_move_nodes(struct pp_qos_dev *qdev) -{ - debug_verify_octet_usage(qdev->octets, 2, 0); - - create_nodes(qdev, 18, 3); - debug_verify_octet_usage(qdev->octets, 2, 3); - - octet_nodes_shift(qdev, 18, 2, -2); - debug_verify_octet_usage(qdev->octets, 2, 3); - - octet_nodes_shift(qdev, 16, 2, 2); - debug_verify_octet_usage(qdev->octets, 2, 3); - - octet_nodes_shift(qdev, 19, 2, 3); - debug_verify_octet_usage(qdev->octets, 2, 3); - - create_nodes(qdev, 26, 4); - debug_verify_octet_usage(qdev->octets, 2, 3); - debug_verify_octet_usage(qdev->octets, 3, 4); - - nodes_move(qdev, 30, 22, 2); - debug_verify_octet_usage(qdev->octets, 2, 1); - debug_verify_octet_usage(qdev->octets, 3, 6); - - destroy_nodes(qdev, 18, 1); - destroy_nodes(qdev, 26, 6); - debug_verify_octet_usage(qdev->octets, 2, 0); - debug_verify_octet_usage(qdev->octets, 3, 0); - - check_consistency(qdev); -} - -static void test_phy_allocation_not_full_octet(struct pp_qos_dev *qdev) -{ - struct qos_node *base; - uint16_t phy; - uint16_t expected_phy; - uint16_t id; - - create_nodes(qdev, 0, 2); - create_nodes(qdev, 16, 6); - - base = get_node_from_phy(qdev->nodes, 0); - - // Port (Node 1) - config_parent_node(qdev, 1, TYPE_PORT, PP_QOS_ARBITRATION_WRR, 16, 2); - - config_parent_node(qdev, 16, TYPE_SCHED, PP_QOS_ARBITRATION_WSP, 18, 2); - config_child_node(qdev, 16, TYPE_SCHED, 1, 0); - config_parent_node(qdev, 17, TYPE_SCHED, PP_QOS_ARBITRATION_WRR, 20, 2); - config_child_node(qdev, 17, TYPE_SCHED, 1, 0); - - // 2 Queues of first sched (Nodes, 18, 19) - // - config_child_node(qdev, 18, TYPE_QUEUE, 16, 3); - config_child_node(qdev, 19, TYPE_QUEUE, 16, 5); - - // 2 Queues of second sched (Nodes, 20, 21) - config_child_node(qdev, 20, TYPE_QUEUE, 17, 3); - config_child_node(qdev, 21, TYPE_QUEUE, 17, 5); - check_consistency(qdev); - - expected_phy = 18; - phy = phy_alloc_by_parent(qdev, base + 16, 1); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 1); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 4, -1); - check_consistency(qdev); - - expected_phy = 19; - phy = phy_alloc_by_parent(qdev, base + 16, 4); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 4); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 3, -1); - check_consistency(qdev); - - expected_phy = 20; - phy = phy_alloc_by_parent(qdev, base + 16, 6); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 6); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - config_parent_node(qdev, 16, TYPE_SCHED, PP_QOS_ARBITRATION_WSP, 18, 2); - octet_nodes_shift(qdev, expected_phy + 1, 2, -1); - check_consistency(qdev); - - expected_phy = 22; - phy = phy_alloc_by_parent(qdev, base + 17, 1); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - - destroy_nodes(qdev, 0, 2); - destroy_nodes(qdev, 16, 7); - check_consistency(qdev); -} - -static void test_phy_allocation_full_octet(struct pp_qos_dev *qdev) -{ - struct qos_node *base; - uint16_t phy; - uint16_t sched; - uint16_t sched2; - uint16_t expected_phy; - uint16_t id; - struct qos_node *node; - - create_nodes(qdev, 0, 2); - create_nodes(qdev, 16, 8); - base = get_node_from_phy(qdev->nodes, 0); - - // Port (Node 1) and 2 scheds - 16(WSP), 17(WRR) - config_parent_node(qdev, 1, TYPE_PORT, PP_QOS_ARBITRATION_WRR, 16, 2); - config_parent_node(qdev, 16, TYPE_SCHED, PP_QOS_ARBITRATION_WSP, 18, 3); - config_child_node(qdev, 16, TYPE_SCHED, 1, 0); - config_parent_node(qdev, 17, TYPE_SCHED, PP_QOS_ARBITRATION_WRR, 21, 3); - config_child_node(qdev, 17, TYPE_SCHED, 1, 0); - - // 3 Queues of first sched (Nodes, 18, 19, 20) - config_child_node(qdev, 18, TYPE_QUEUE, 16, 1); - config_child_node(qdev, 19, TYPE_QUEUE, 16, 3); - config_child_node(qdev, 20, TYPE_QUEUE, 16, 5); - - // 3 Queues of second sched (Nodes, 21, 22, 23) - config_child_node(qdev, 23, TYPE_QUEUE, 17, 0); - config_child_node(qdev, 21, TYPE_QUEUE, 17, 0); - config_child_node(qdev, 22, TYPE_QUEUE, 17, 0); - check_consistency(qdev); - - sched = get_id_from_phy(qdev->mapping, 16); - sched2 = get_id_from_phy(qdev->mapping, 17); - - expected_phy = 17; - phy = phy_alloc_by_parent(qdev, base + 16, 2); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 2); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 5, -1); - check_consistency(qdev); - octet_nodes_shift(qdev, 16, 6, 2); - phy = get_phy_from_id(qdev->mapping, sched); - nodes_move(qdev, 16, phy, 2); - check_consistency(qdev); - - expected_phy = 18; - phy = phy_alloc_by_parent(qdev, base + 16, 4); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 4); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 4, -1); - check_consistency(qdev); - octet_nodes_shift(qdev, 16, 6, 2); - phy = get_phy_from_id(qdev->mapping, sched); - nodes_move(qdev, 16, phy, 2); - check_consistency(qdev); - - expected_phy = 16; - phy = phy_alloc_by_parent(qdev, base + 16, 0); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 0); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 6, -1); - check_consistency(qdev); - octet_nodes_shift(qdev, 16, 6, 2); - phy = get_phy_from_id(qdev->mapping, sched); - nodes_move(qdev, 16, phy, 2); - check_consistency(qdev); - - - expected_phy = 19; - phy = phy_alloc_by_parent(qdev, base + 16, 6); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 6); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - node = get_node_from_phy(qdev->nodes, get_phy_from_id(qdev->mapping, sched)); - node->parent_prop.num_of_children--; - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 3, -1); - check_consistency(qdev); - - octet_nodes_shift(qdev, 16, 6, 2); - phy = get_phy_from_id(qdev->mapping, sched); - nodes_move(qdev, 16, phy, 2); - check_consistency(qdev); - - expected_phy = 22; - phy = phy_alloc_by_parent(qdev, base + 17, 0); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - check_consistency(qdev); - node = get_node_from_phy(qdev->nodes, get_phy_from_id(qdev->mapping, sched2)); - node->parent_prop.num_of_children--; - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, 16, 6, 2); - phy = get_phy_from_id(qdev->mapping, sched); - nodes_move(qdev, 16, phy, 2); - check_consistency(qdev); - - destroy_nodes(qdev, 16, 8); - destroy_nodes(qdev, 0, 2); - check_consistency(qdev); -} - -static void test_phy_allocation_full_octet_2(struct pp_qos_dev *qdev) -{ - struct qos_node *base; - uint16_t phy; - uint16_t queue; - uint16_t expected_phy; - uint16_t id; - - create_nodes(qdev, 0, 2); - create_nodes(qdev, 16, 8); - base = get_node_from_phy(qdev->nodes, 0); - - // Port (Node 1) and 2 scheds - 16(WSP), 17(WRR) - config_parent_node(qdev, 1, TYPE_PORT, PP_QOS_ARBITRATION_WRR, 16, 2); - config_parent_node(qdev, 16, TYPE_SCHED, PP_QOS_ARBITRATION_WSP, 18, 5); - config_child_node(qdev, 16, TYPE_SCHED, 1, 0); - config_parent_node(qdev, 17, TYPE_SCHED, PP_QOS_ARBITRATION_WRR, 23, 1); - config_child_node(qdev, 17, TYPE_SCHED, 1, 0); - - // 4 Queues of first sched (Nodes, 18, 19, 20, 21, 22) - config_child_node(qdev, 18, TYPE_QUEUE, 16, 1); - config_child_node(qdev, 19, TYPE_QUEUE, 16, 3); - config_child_node(qdev, 20, TYPE_QUEUE, 16, 5); - config_child_node(qdev, 21, TYPE_QUEUE, 16, 6); - config_child_node(qdev, 22, TYPE_QUEUE, 16, 7); - - // 1 Queues of second sched (Node 23) - config_child_node(qdev, 23, TYPE_QUEUE, 17, 0); - queue = get_id_from_phy(qdev->mapping, 23); - check_consistency(qdev); - - expected_phy = 18; - phy = phy_alloc_by_parent(qdev, base + 16, 0); - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 0); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, expected_phy + 1, 5, -1); - check_consistency(qdev); - phy = get_phy_from_id(qdev->mapping, queue); - nodes_move(qdev, 23, phy, 1); - check_consistency(qdev); - - // - // change config to 3 schedulers, first has 1 child, second 4 and third - // none - // - config_parent_node(qdev, 1, TYPE_PORT, PP_QOS_ARBITRATION_WRR, 16, 3); - config_parent_node(qdev, 16, TYPE_SCHED, PP_QOS_ARBITRATION_WSP, 19, 1); - config_parent_node(qdev, 17, TYPE_SCHED, PP_QOS_ARBITRATION_WRR, 20, 4); - config_child_node(qdev, 18, TYPE_SCHED, 1, 0); - config_child_node(qdev, 19, TYPE_QUEUE, 16, 3); - config_child_node(qdev, 23, TYPE_QUEUE, 17, 0); - config_child_node(qdev, 20, TYPE_QUEUE, 17, 0); - config_child_node(qdev, 21, TYPE_QUEUE, 17, 0); - config_child_node(qdev, 22, TYPE_QUEUE, 17, 0); - check_consistency(qdev); - - queue = get_id_from_phy(qdev->mapping, 19); - phy = phy_alloc_by_parent(qdev, base + 16, 0); - expected_phy = get_phy_from_id(qdev->mapping, queue) - 1; - QOS_ASSERT(phy == expected_phy, "Expected phy for new node %d but got %d\n", expected_phy, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, 0); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - destroy_nodes(qdev, phy, 1); - octet_nodes_shift(qdev, phy + 1, 1, -1); - check_consistency(qdev); - - destroy_nodes(qdev, 16, 7); - destroy_nodes(qdev, 0, 2); - destroy_nodes(qdev, phy, 1); - check_consistency(qdev); -} - -static void test_internal_scheduler(struct pp_qos_dev *qdev) -{ - uint16_t phy; - struct qos_node *base; - int i; - uint16_t id; - - base = get_node_from_phy(qdev->nodes, 0); - create_nodes(qdev, 0, 2); - create_nodes(qdev, 16, 8); - config_parent_node(qdev, 1, TYPE_PORT, PP_QOS_ARBITRATION_WRR, 16, 8); - config_child_node(qdev, 16, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 17, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 18, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 19, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 20, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 21, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 22, TYPE_QUEUE, 1, 0); - config_child_node(qdev, 23, TYPE_QUEUE, 1, 0); - check_consistency(qdev); - - for (i = 0 ; i < 200; ++i) { - phy = phy_alloc_by_parent(qdev, base + 1, 0); - id = pp_pool_get(qdev->ids); - map_id_phy(qdev->mapping, id, phy); - config_child_node(qdev, phy, TYPE_QUEUE, QOS_INVALID_PHY, QOS_INVALID_PRIORITY); - check_consistency(qdev); - } - -} - -static void expected_id_phy(const struct pp_qos_dev *qdev, int id, int eid, int ephy) -{ - int phy; - - phy = get_phy_from_id(qdev->mapping, id); - QOS_ASSERT(id == eid, "Got id %d expected %d\n", id, eid); - QOS_ASSERT(phy == ephy, "Got phy %d expected %d\n", phy, ephy); -} - -static void test_ports(struct pp_qos_dev *qdev) -{ - struct pp_qos_port_conf conf; - unsigned int id1; - unsigned int id2; - int tmp; - struct qos_node *node; - struct pp_qos_port_info info; - uint16_t ids[5]; - unsigned tmp2; - unsigned firstnonport; - - QOS_LOG_INFO("starting ports tests\n"); - firstnonport = qdev->max_port + 1; - - /* Allocate port with arbitrary phy */ - tmp = pp_qos_port_allocate(qdev, ALLOC_PORT_ID, &id1); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - expected_id_phy(qdev, id1, 0, 0); - - pp_qos_port_conf_set_default(&conf); - conf.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - conf.ring_address = (void *)1; - conf.ring_size = 1; - QOS_ASSERT(pp_qos_port_set(qdev, id1, &conf) == 0, "Could not set port\n"); - - node = get_node_from_phy(qdev->nodes, get_phy_from_id(qdev->mapping, id1)); - conf.ring_size = 3; - QOS_ASSERT(pp_qos_port_set(qdev, id1, &conf) == 0, "Could not set port\n"); - QOS_ASSERT(port_cfg_valid(qdev, node, node), "Configuration not valid\n"); - - conf.ring_size = 0; - QOS_ASSERT(pp_qos_port_set(qdev, id1, &conf) == -EINVAL, "Port setting should have failed\n"); - QOS_ASSERT(port_cfg_valid(qdev, node, node), "Configuration not valid\n"); - - /* Allocate port with certain phy */ - tmp = pp_qos_port_allocate(qdev, 10, &id2); - QOS_ASSERT(tmp == -EINVAL, "Port allocation should have failed\n"); - tmp = pp_qos_port_allocate(qdev, 12, &id2); - QOS_ASSERT(tmp == 0, "Port allocation failed\n"); - expected_id_phy(qdev, id2, 1, 12); - tmp = pp_qos_port_allocate(qdev, 12, &id2); - QOS_ASSERT(tmp == -EBUSY, "Port allocation should have failed\n"); - create_nodes(qdev, firstnonport, 3); - config_child_node(qdev, firstnonport, TYPE_QUEUE, 12, 0); - config_child_node(qdev, firstnonport + 1, TYPE_QUEUE, 12, 0); - config_child_node(qdev, firstnonport + 2, TYPE_QUEUE, 12, 0); - config_parent_node(qdev, 12, TYPE_PORT, PP_QOS_ARBITRATION_WRR, firstnonport, 3); - pp_qos_port_info_get(qdev, id2, &info); - QOS_ASSERT(info.num_of_queues == 3 && info.physical_id == 12, "Number of queues %d or phy %d is not what expected\n", info.num_of_queues, info.physical_id); - - pp_qos_port_get_queues(qdev, id2, ids, 2, &tmp2); - QOS_ASSERT((tmp2 == 3) && (ids[0] == 2) && (ids[1] == 3), "Number of queues %d or ids %d %d are not expected\n", tmp2, ids[0], ids[1]); - - pp_qos_port_remove(qdev, id1); - pp_qos_port_remove(qdev, id2); - - - check_consistency(qdev); - QOS_LOG_INFO("ports tests completed successfully :)\n"); -} - -static void expected_queues(struct pp_qos_dev *qdev, int phy, unsigned exp) -{ - unsigned num; - - get_node_queues(qdev, phy, NULL, 0, &num); - QOS_ASSERT(exp == num, "Expected %u queues on phy %d but got %u\n", exp, phy, num); -} - -static void test_queues1(struct pp_qos_dev *qdev) -{ - int tmp; - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - struct qos_node node; - struct qos_node *nodep; - unsigned int p1; - unsigned int p7; - unsigned int q[100]; - unsigned int j; - unsigned int i; - unsigned firstnonport; - - QOS_LOG_INFO("starting queues1 tests\n"); - firstnonport = qdev->max_port + 1; - - /* Allocate port 1 */ - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - tmp = pp_qos_port_allocate(qdev, 1, &p1); - expected_id_phy(qdev, p1, 0, 1); - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - check_consistency_with_resources(qdev); - - /* Allocate first queue */ - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p1; - tmp = pp_qos_queue_allocate(qdev, &q[0]); - pp_qos_queue_set(qdev, q[0], &confq); - expected_id_phy(qdev, q[0], 1, firstnonport); - check_consistency_with_resources(qdev); - - - /* Allocate 7 more queues */ - for (i = 1; i < 8; ++ i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - confq.queue_wred_max_allowed = i; - pp_qos_queue_set(qdev, q[i], &confq); - expected_id_phy(qdev, q[i], i + 1, firstnonport + i); - check_consistency_with_resources(qdev); - } - - /* Allocate 64 more queues */ - for (i = 8; i < 72; ++i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - confq.queue_wred_max_allowed = i; - pp_qos_queue_set(qdev, q[i], &confq); - check_consistency_with_resources(qdev); - } - - /* change setting without parent */ - tmp = get_phy_from_id(qdev->mapping, q[7]); - nodep = get_node_from_phy(qdev->nodes, tmp); - memcpy(&node, nodep, sizeof(struct qos_node)); - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[7], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_wred_max_allowed = 77; - pp_qos_queue_set(qdev, q[7], &confq); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, data.queue.max_allowed)) == 0, "Unexpected change\n"); - QOS_ASSERT(nodep->data.queue.max_allowed == 77, "Set max allowed did not work\n"); - QOS_ASSERT(memcmp(&(node.data.queue.min_guaranteed), &(nodep->data.queue.min_guaranteed), sizeof(struct qos_node) - offsetof(struct qos_node, data.queue.min_guaranteed)) == 0, "Unexpected change\n"); - check_consistency_with_resources(qdev); - - /* change setting with parent */ - tmp = pp_qos_port_allocate(qdev, 7, &p7); - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - - tmp = get_phy_from_id(qdev->mapping, q[14]); - nodep = get_node_from_phy(qdev->nodes, tmp); - memcpy(&node, nodep, sizeof(struct qos_node)); - - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[14], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_child_prop.parent = p7; - confq.queue_wred_max_allowed = 777; - pp_qos_queue_set(qdev, q[14], &confq); - tmp = get_phy_from_id(qdev->mapping, q[14]); - nodep = get_node_from_phy(qdev->nodes, tmp); - QOS_ASSERT(nodep->data.queue.max_allowed == 777, "Set max allowed not work\n"); - QOS_ASSERT(nodep->child_prop.parent_phy == get_phy_from_id(qdev->mapping, p7), "Set of parent did not work has %d instead of %d\n", - nodep->child_prop.parent_phy, get_phy_from_id(qdev->mapping, p7)); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.child_prop.priority), &(nodep->child_prop.priority), offsetof(struct qos_node, data.queue.max_allowed) - offsetof(struct qos_node, child_prop.priority)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.data.queue.min_guaranteed), &(nodep->data.queue.min_guaranteed), sizeof(struct qos_node) - offsetof(struct qos_node, data.queue.min_guaranteed)) == 0, "Unexpected change\n"); - - check_consistency_with_resources(qdev); - - for (j = 0 ; j < 100; ++j) { - for (i = 20; i < 50; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 300 + i; - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - - for (i = 20; i < 50; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 400 + i; - confq.queue_child_prop.parent = p1; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - } - QOS_LOG_INFO("queue1 tests completed successfully :)\n"); -} -static void test_queues2(struct pp_qos_dev *qdev) -{ - int tmp; - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - struct qos_node node; - struct qos_node *nodep; - unsigned int p1; - unsigned int p7; - unsigned int p12; - unsigned int q[100]; - unsigned int j; - unsigned int i; - unsigned tmp1; - unsigned tmp2; - unsigned tmp3; - unsigned tmp4; - unsigned firstnonport; - - QOS_LOG_INFO("starting queues2 tests\n"); - firstnonport = qdev->max_port + 1; - - - /* Allocate port 1 */ - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - tmp = pp_qos_port_allocate(qdev, 1, &p1); - expected_id_phy(qdev, p1, 0, 1); - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - check_consistency_with_resources(qdev); - - /* Allocate first queue */ - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p1; - tmp = pp_qos_queue_allocate(qdev, &q[0]); - pp_qos_queue_set(qdev, q[0], &confq); - expected_id_phy(qdev, q[0], 1, firstnonport); - check_consistency_with_resources(qdev); - - - /* Allocate 7 more queues */ - for (i = 1; i < 8; ++ i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - confq.queue_wred_max_allowed = i; - pp_qos_queue_set(qdev, q[i], &confq); - expected_id_phy(qdev, q[i], i + 1, firstnonport + i); - check_consistency_with_resources(qdev); - } - - /* Allocate 64 more queues */ - for (i = 8; i < 100; ++i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - confq.queue_wred_max_allowed = i; - confq.queue_child_prop.bandwidth_share = 1; - pp_qos_queue_set(qdev, q[i], &confq); - check_consistency_with_resources(qdev); - } - - /* change setting without parent */ - tmp = get_phy_from_id(qdev->mapping, q[7]); - nodep = get_node_from_phy(qdev->nodes, tmp); - memcpy(&node, nodep, sizeof(struct qos_node)); - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[7], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_wred_max_allowed = 77; - pp_qos_queue_set(qdev, q[7], &confq); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, data.queue.max_allowed)) == 0, "Unexpected change\n"); - QOS_ASSERT(nodep->data.queue.max_allowed == 77, "Set max allowed did not work\n"); - QOS_ASSERT(memcmp(&(node.data.queue.min_guaranteed), &(nodep->data.queue.min_guaranteed), sizeof(struct qos_node) - offsetof(struct qos_node, data.queue.min_guaranteed)) == 0, "Unexpected change\n"); - check_consistency_with_resources(qdev); - - /* allocate port 7 and port 12 */ - tmp = pp_qos_port_allocate(qdev, 7, &p7); - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - tmp = pp_qos_port_allocate(qdev, 12, &p12); - QOS_ASSERT(pp_qos_port_set(qdev, p12, &confp) == 0, "Could not set port\n"); - - /* change setting with parent */ - tmp = get_phy_from_id(qdev->mapping, q[14]); - nodep = get_node_from_phy(qdev->nodes, tmp); - memcpy(&node, nodep, sizeof(struct qos_node)); - - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[14], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_child_prop.parent = p7; - confq.queue_wred_max_allowed = 777; - pp_qos_queue_set(qdev, q[14], &confq); - tmp = get_phy_from_id(qdev->mapping, q[14]); - nodep = get_node_from_phy(qdev->nodes, tmp); - QOS_ASSERT(nodep->data.queue.max_allowed == 777, "Set max allowed not work\n"); - QOS_ASSERT(nodep->child_prop.parent_phy == get_phy_from_id(qdev->mapping, p7), "Set of parent did not work has %d instead of %d\n", - nodep->child_prop.parent_phy, get_phy_from_id(qdev->mapping, p7)); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.child_prop.priority), &(nodep->child_prop.priority), offsetof(struct qos_node, data.queue.max_allowed) - offsetof(struct qos_node, child_prop.priority)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.data.queue.min_guaranteed), &(nodep->data.queue.min_guaranteed), sizeof(struct qos_node) - offsetof(struct qos_node, data.queue.min_guaranteed)) == 0, "Unexpected change\n"); - - check_consistency_with_resources(qdev); - - tmp = get_phy_from_id(qdev->mapping, q[21]); - nodep = get_node_from_phy(qdev->nodes, tmp); - memcpy(&node, nodep, sizeof(struct qos_node)); - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[21], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_child_prop.parent = p12; - confq.queue_wred_max_allowed = 2121; - pp_qos_queue_set(qdev, q[21], &confq); - tmp = get_phy_from_id(qdev->mapping, q[21]); - nodep = get_node_from_phy(qdev->nodes, tmp); - QOS_ASSERT(nodep->data.queue.max_allowed == 2121, "Set max allowed not work\n"); - QOS_ASSERT(nodep->child_prop.parent_phy == get_phy_from_id(qdev->mapping, p12), "Set of parent did not work has %d instead of %d\n", - nodep->child_prop.parent_phy, get_phy_from_id(qdev->mapping, p12)); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&node, nodep, offsetof(struct qos_node, child_prop.parent_phy)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.child_prop.priority), &(nodep->child_prop.priority), offsetof(struct qos_node, data.queue.max_allowed) - offsetof(struct qos_node, child_prop.priority)) == 0, "Unexpected change\n"); - QOS_ASSERT(memcmp(&(node.data.queue.min_guaranteed), &(nodep->data.queue.min_guaranteed), sizeof(struct qos_node) - offsetof(struct qos_node, data.queue.min_guaranteed)) == 0, "Unexpected change\n"); - - - check_consistency_with_resources(qdev); - expected_queues(qdev, 1, 98); - expected_queues(qdev, 7, 1); - expected_queues(qdev, 12, 1); - for (i = 25; i < 50; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 300 + i; - confq.queue_child_prop.parent = p12; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - expected_queues(qdev, 1, 73); - expected_queues(qdev, 7, 1); - expected_queues(qdev, 12, 26); - - for (i = 50; i < 70; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 400 + i; - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - expected_queues(qdev, 1, 53); - expected_queues(qdev, 7, 21); - expected_queues(qdev, 12, 26); - - for (i = 25; i < 45; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 500 + i; - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - - expected_queues(qdev, 1, 53); - expected_queues(qdev, 7, 41); - expected_queues(qdev, 12, 6); - for (i = 45; i < 60; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 600 + i; - confq.queue_child_prop.parent = p12; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - expected_queues(qdev, 1, 53); - expected_queues(qdev, 7, 31); - expected_queues(qdev, 12, 16); - - for (i = 60; i < 70; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 700 + i; - confq.queue_child_prop.parent = p1; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - expected_queues(qdev, 1, 63); - expected_queues(qdev, 7, 21); - expected_queues(qdev, 12, 16); - for (j = 0 ; j < 100; ++j) { - for (i = 50; i < 70; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 400 + i; - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - - for (i = 25; i < 45; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 500 + i; - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - - for (i = 45; i < 60; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 600 + i; - confq.queue_child_prop.parent = p12; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - - for (i = 60; i < 70; ++i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed on %d iteration\n", i); - confq.queue_wred_max_allowed = 700 + i; - confq.queue_child_prop.parent = p1; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - check_consistency_with_resources(qdev); - } - } - - - get_node_queues(qdev, 1, NULL, 0, &tmp1); - get_node_queues(qdev, 7, NULL, 0, &tmp2); - get_node_queues(qdev, 12, NULL, 0, &tmp3); - tmp4 = tmp1 + tmp2 + tmp3; - QOS_ASSERT(tmp4 == 100, "Number of queues expected to be 100 but it is %u\n", tmp4); - - QOS_LOG_INFO("queue2 tests completed successfully :)\n"); - -} - -static void test_queues3(struct pp_qos_dev *qdev) -{ - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - unsigned int p1; - unsigned int q[100]; - unsigned int i; - int tmp; - unsigned int bw[] = { 13, 0, 20, 17, 0, 0, 0, 8 }; - unsigned firstnonport; - - QOS_LOG_INFO("starting queues3 tests\n"); - firstnonport = qdev->max_port + 1; - - /* Allocate port 1 */ - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - tmp = pp_qos_port_allocate(qdev, 1, &p1); - expected_id_phy(qdev, p1, 0, 1); - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - check_consistency_with_resources(qdev); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p1; - - /* Allocate 7 queues */ - for (i = 0; i < 7; ++ i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_wred_max_allowed = i; - confq.queue_child_prop.bandwidth_share = 13; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - check_consistency_with_resources(qdev); - - /* Try to add a new queue with a share that cross 100 */ - tmp = pp_qos_queue_allocate(qdev, &q[7]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_wred_max_allowed = 8; - confq.queue_child_prop.bandwidth_share = 10; - QOS_ASSERT(pp_qos_queue_set(qdev, q[7], &confq) != 0, "Set should have failed due to over bandwidth\n"); - pp_pool_put(qdev->ids, q[7]); - check_consistency_with_resources(qdev); - - - /* Change setting on existing node */ - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[6], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - confq.queue_child_prop.bandwidth_share = 15; - QOS_ASSERT(pp_qos_queue_set(qdev, q[6], &confq) == 0, "Set failed\n"); - - - /* Add a new queue that does not cross 100קד*/ - tmp = pp_qos_queue_allocate(qdev, &q[7]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_wred_max_allowed = 8; - confq.queue_child_prop.bandwidth_share = 6; - QOS_ASSERT(pp_qos_queue_set(qdev, q[7], &confq) == 0, "Set have failed\n"); - check_consistency_with_resources(qdev); - - for (i = 0; i < 8; ++ i) { - QOS_ASSERT(pp_qos_queue_conf_get(qdev, q[i], &confq) == 0, "pp_qos_queue_conf_get failed\n"); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_child_prop.bandwidth_share = bw[i]; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - - tmp = pp_qos_queue_allocate(qdev, &q[8]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_child_prop.bandwidth_share = 10; - QOS_ASSERT(pp_qos_queue_set(qdev, q[8], &confq) == 0, "Could not set queue\n"); - check_consistency_with_resources(qdev); - - for (i = 9; i < 64; ++ i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_child_prop.bandwidth_share = 0; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - check_consistency_with_resources(qdev); - } - - tmp = pp_qos_queue_allocate(qdev, &q[64]); - QOS_ASSERT(tmp == 0, "Could not allocate queue\n"); - confq.queue_child_prop.bandwidth_share = 15; - QOS_ASSERT(pp_qos_queue_set(qdev, q[64], &confq) == 0, "Could not set queue\n"); - - pp_qos_queue_remove(qdev, q[64]); - check_consistency_with_resources(qdev); - - tree_remove(qdev, firstnonport); - check_consistency_with_resources(qdev); - - QOS_LOG_INFO("queue3 tests completed successfully :)\n"); -} - - -static void reposition_internal_test(struct pp_qos_dev *qdev) -{ - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - struct pp_qos_sched_conf confs; - - unsigned int p89; - unsigned int p97; - unsigned int p105; - unsigned int p7; - unsigned int q[200]; - unsigned int s[5]; - unsigned int i; - int tmp; - - QOS_LOG_INFO("reposition test started\n"); - - qdev->reserved_ports[89] = 1; - qdev->reserved_ports[97] = 1; - qdev->reserved_ports[105] = 1; - tmp = pp_qos_port_allocate(qdev, 7, &p7); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - tmp = pp_qos_port_allocate(qdev, 89, &p89); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - tmp = pp_qos_port_allocate(qdev, 97, &p97); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - tmp = pp_qos_port_allocate(qdev, 105, &p105); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - confp.ring_address = (void *)950000; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - - confp.ring_address = (void *)950600; - QOS_ASSERT(pp_qos_port_set(qdev, p89, &confp) == 0, "Could not set port\n"); - - confp.ring_address = (void *)950700; - QOS_ASSERT(pp_qos_port_set(qdev, p97, &confp) == 0, "Could not set port\n"); - - confp.ring_address = (void *)950800; - QOS_ASSERT(pp_qos_port_set(qdev, p105, &confp) == 0, "Could not set port\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p89; - for (i = 0; i < 200; ++ i) { - tmp = pp_qos_queue_allocate(qdev, &q[i]); - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "q set failed\n"); - } - - /* moving queues from p89 to p7 */ - confq.queue_child_prop.parent = p7; - for (i = 0; i < 200; ++i) - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "q set failed\n"); - - check_consistency_with_resources(qdev); - - for (i = 0; i < 195; ++i) - QOS_ASSERT(pp_qos_queue_remove(qdev, q[i]) == 0, "q remove failed\n"); - check_consistency_with_resources(qdev); - - pp_qos_sched_conf_set_default(&confs); - for (i = 0; i < 5; ++i) { - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s[i]) == 0, "Could not allocate sched\n"); - if (i == 0) - confs.sched_child_prop.parent = p97; - else - confs.sched_child_prop.parent = s[i - 1]; - QOS_ASSERT(pp_qos_sched_set(qdev, s[i], &confs) == 0, "Could not set sched\n"); - } - - check_consistency_with_resources(qdev); - - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[0]) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = s[4]; - QOS_ASSERT(pp_qos_queue_set(qdev, q[0], &confq) == 0, "Could not set queue\n"); - check_consistency_with_resources(qdev); - - confs.sched_child_prop.parent = p97; - QOS_ASSERT(pp_qos_sched_set(qdev, s[3], &confs) == 0, "Could not set sched\n"); - check_consistency_with_resources(qdev); - - confs.sched_child_prop.parent = p105; - QOS_ASSERT(pp_qos_sched_set(qdev, s[4], &confs) == 0, "Could not set sched\n"); - check_consistency_with_resources(qdev); - QOS_LOG_INFO("reposition test completed successfully :)\n"); - -} - -static struct pp_qos_dev *test_open_and_init_instance(unsigned int instance) -{ - int rc; - struct pp_qos_init_param initp; - struct pp_qos_dev *qdev; - - qdev = pp_qos_dev_open(instance); - if (qdev) { - if (!qdev->initialized) { - memset(&initp, 0, sizeof(initp)); - initp.wred_total_avail_resources = 0x10000; - initp.wred_p_const = 512; - initp.wred_max_q_size = 10000; - initp.reserved_ports[1] = 1; - initp.reserved_ports[7] = 1; - initp.reserved_ports[12] = 1; - rc = pp_qos_dev_init(qdev, &initp); - QOS_ASSERT(rc == 0, "Init of instance 0 failed\n"); - } else { - QOS_LOG_INFO("Device %u already initialized\n", instance); - } - } else { - QOS_LOG_ERR("Could not open device %u\n", instance); - } - return qdev; -} - - -static void test_shared_group(struct pp_qos_dev *qdev) -{ - int rc; - unsigned int id1; - unsigned int id2; - unsigned int p; - unsigned int q[10]; - unsigned int phy; - unsigned int gid; - uint16_t members[5]; - unsigned int members_num; - int i; - struct qos_node *node; - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - - QOS_LOG_INFO("starting shared group tests\n"); - - rc = pp_qos_shared_limit_group_add(qdev, 100, &id1); - QOS_ASSERT(rc == 0 && id1 == 1, "Return code is %d id is %u expected 1\n", rc ,id1); - - rc = pp_qos_shared_limit_group_add(qdev, 200, &id2); - QOS_ASSERT(rc == 0 && id2 == 2, "Return code is %d id is %u expected 2\n", rc ,id2); - - rc = pp_qos_shared_limit_group_remove(qdev, 3); - QOS_ASSERT(rc == -EINVAL, "Removing not existent group should have failed\n"); - - rc = pp_qos_shared_limit_group_remove(qdev, id2); - QOS_ASSERT(rc == 0, "Removing failed with %d\n", rc); - - rc = pp_qos_shared_limit_group_modify(qdev, id2, 500); - QOS_ASSERT(rc == -EINVAL, "Modifying not existent group should have failed\n"); - - rc = pp_qos_shared_limit_group_modify(qdev, id1, 100); - QOS_ASSERT(rc == 0, "Modifying group failed with %d\n", rc); - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - rc = pp_qos_port_allocate(qdev, 1, &p); - QOS_ASSERT(pp_qos_port_set(qdev, p, &confp) == 0, "Could not set port\n"); - node = get_node_from_phy(qdev->nodes, 1); - QOS_ASSERT(node->shared_bandwidth_group == QOS_NO_SHARED_BANDWIDTH_GROUP, "shared bandwidth group shoud be %u but it is %u\n", QOS_NO_SHARED_BANDWIDTH_GROUP, - node->shared_bandwidth_group); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p; - - /* Allocate 7 queues */ - for (i = 0; i < 7; ++ i) { - rc = pp_qos_queue_allocate(qdev, &q[i]); - QOS_ASSERT(rc == 0, "Could not allocate queue\n"); - - if (i > 3) - confq.common_prop.shared_bandwidth_group = id1; - else - confq.common_prop.shared_bandwidth_group = 0; - - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - - for (i = 0; i < 7; ++i) { - phy = get_phy_from_id(qdev->mapping, q[i]); - node = get_node_from_phy(qdev->nodes, phy); - gid = node->shared_bandwidth_group; - if (i > 3) - QOS_ASSERT(gid == id1, "shared group id is %u expected %u\n", gid, id1); - else - - QOS_ASSERT(gid == QOS_NO_SHARED_BANDWIDTH_GROUP, "shared group id is %u expected %u\n", gid, QOS_NO_SHARED_BANDWIDTH_GROUP); - } - - rc = pp_qos_queue_allocate(qdev, &q[8]); - QOS_ASSERT(rc == 0, "Could not allocate queue\n"); - confq.common_prop.shared_bandwidth_group = 10; - QOS_ASSERT(pp_qos_queue_set(qdev, q[8], &confq) == -EINVAL, "Illegal shared group, should have failed\n"); - pp_pool_put(qdev->ids, q[8]); - - - - rc = pp_qos_shared_limit_group_get_members(qdev, id1, members, 5, &members_num); - QOS_ASSERT(rc == 0 && members_num == 3, "get_members returned %d, expected number of members to be %u but it is %u\n", - rc, 3 , members_num); - - QOS_ASSERT(members[0] == q[4] && members[1] == q[5] && members[2] == q[6], "Unexpected members %u %u %u\n", members[0], members[1], members[2]); - - /* Block removing of queue with members */ - rc = pp_qos_shared_limit_group_remove(qdev, id1); - QOS_ASSERT(rc == -EBUSY, "Removing group with members should fail\n"); - - confq.common_prop.shared_bandwidth_group = 0; - - QOS_ASSERT(pp_qos_queue_set(qdev, q[4], &confq) == 0, "Could not set queue\n"); - rc = pp_qos_shared_limit_group_remove(qdev, id1); - QOS_ASSERT(rc == -EBUSY, "Removing group with members should fail\n"); - - QOS_ASSERT(pp_qos_queue_set(qdev, q[5], &confq) == 0, "Could not set queue\n"); - rc = pp_qos_shared_limit_group_remove(qdev, id1); - QOS_ASSERT(rc == -EBUSY, "Removing group with members should fail\n"); - - check_consistency_with_resources(qdev); - - QOS_ASSERT(pp_qos_queue_set(qdev, q[6], &confq) == 0, "Could not set queue\n"); - rc = pp_qos_shared_limit_group_remove(qdev, id1); - QOS_ASSERT(rc == 0, "Removing group failed\n"); - - - check_consistency_with_resources(qdev); - QOS_LOG_INFO("shared group tests completed successfully :)\n"); -} - - -/* - * p1 p7 - * s0 s1 q3 - * q0 s2 q1 - * q2 - */ -void test_cmd_queue(void) -{ - struct pp_qos_dev *qdev; - struct pp_qos_port_conf confp; - struct pp_qos_sched_conf confs; - struct pp_qos_queue_conf confq; - unsigned int p1; - unsigned int p7; - unsigned int s0; - unsigned int s1; - unsigned int s2; - unsigned int q0; - unsigned int q1; - unsigned int q2; - unsigned int q3; - unsigned int q[10]; - unsigned int i; - unsigned firstnonport; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - firstnonport = qdev->max_port + 1; - QOS_LOG_INFO("starting cmd queue tests\n"); - // Add ports 1 and 7 - QOS_ASSERT(pp_qos_port_allocate(qdev, 1, &p1) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p7) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - - // Add schedulers - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s0) == 0, "Could not allocate sched\n"); - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s1) == 0, "Could not allocate sched\n"); - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s2) == 0, "Could not allocate sched\n"); - pp_qos_sched_conf_set_default(&confs); - confs.sched_child_prop.parent = p1; - QOS_ASSERT(pp_qos_sched_set(qdev, s0, &confs) == 0, "Could not set sched\n"); - QOS_ASSERT(pp_qos_sched_set(qdev, s1, &confs) == 0, "Could not set sched\n"); - confs.sched_child_prop.parent = s0; - confs.sched_child_prop.bandwidth_share = 7; - QOS_ASSERT(pp_qos_sched_set(qdev, s2, &confs) == 0, "Could not set sched\n"); - - // Add queues - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q0) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q1) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q2) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q3) == 0, "Could not allocate queue\n"); - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = s0; - QOS_ASSERT(pp_qos_queue_set(qdev, q0, &confq) == 0, "Could not set queue\n"); - confq.queue_child_prop.parent = s1; - QOS_ASSERT(pp_qos_queue_set(qdev, q1, &confq) == 0, "Could not set queue\n"); - confq.queue_child_prop.parent = s2; - QOS_ASSERT(pp_qos_queue_set(qdev, q2, &confq) == 0, "Could not set queue\n"); - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q3, &confq) == 0, "Could not set queue\n"); - - check_consistency_with_resources(qdev); - nodes_move(qdev, 32, firstnonport, 7); - check_consistency_with_resources(qdev); - - - /* s0 has 2 children, adding 5 more */ - confq.queue_child_prop.parent = s0; - confq.queue_child_prop.bandwidth_share = 7; - for (i = 0; i < 5; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[i]) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[5]) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[5], &confq) == 0, "Could not set queue\n"); - - /* This should call create internal scheduler */ - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[6]) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[6], &confq) == 0, "Could not set queue\n"); - - check_consistency_with_resources(qdev); - - //transmit_cmds(qdev); - -#if 0 - // Modify port arbitration - confp.common_prop.bandwidth_limit = 10; - QOS_ASSERT(pp_qos_port_set(qdev, p0, &confp) == 0, "Could not set port\n"); - - - // Add queue under port - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q0) == 0, "Could not allocate queue\n"); - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.priority = 0; - confq.queue_child_prop.parent = p0; - QOS_ASSERT(pp_qos_queue_set(qdev, q0, &confq) == 0, "Could not set queue\n"); - check_consistency_with_resources(qdev); - - // Modify queue - confq.queue_child_prop.bandwidth_share = 10; - QOS_ASSERT(pp_qos_queue_set(qdev, q0, &confq) == 0, "Could not set queue\n"); - - for (i = 0; i < 7; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, q + i) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - - QOS_ASSERT(pp_qos_queue_allocate(qdev, q + 7) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[7], &confq) == 0, "Could not set queue\n"); - // Remove port - QOS_ASSERT(pp_qos_port_remove(qdev, p0) == 0, "Could not remove port\n"); - check_consistency_with_resources(qdev); -#endif - - QOS_LOG_INFO("cmd queue tests completed successfully :)\n"); -} - -struct pp_mapping { - uint16_t id2phy[NUM_OF_NODES]; - uint16_t phy2id[NUM_OF_NODES]; -}; -struct octet_info { - struct list_head list; - uint8_t usage; -}; -struct pp_octets { - int last_port_octet; - struct octet_info info[NUM_OF_OCTETS]; - struct list_head lists[9]; -}; -struct pp_nodes { - struct qos_node nodes[NUM_OF_NODES]; -}; -static void reset_qos_dev(struct pp_qos_dev *dst, struct pp_qos_dev *src) -{ - - memcpy(dst->groups, src->groups, sizeof(dst->groups)); - *(dst->ids) = *(src->ids); - memcpy(dst->ids->data, src->ids->data, dst->ids->capacity * sizeof(dst->ids->data[0])); - *(dst->rlms) = *(src->rlms); - memcpy(dst->rlms->data, src->rlms->data, dst->rlms->capacity * sizeof(dst->rlms->data[0])); - *(dst->portsphys) = *(src->portsphys); - memcpy(dst->portsphys->data, src->portsphys->data, dst->portsphys->capacity * sizeof(dst->portsphys->data[0])); - - memcpy(dst->nodes, src->nodes, sizeof(struct pp_nodes)); - memcpy(dst->mapping, src->mapping, sizeof(struct pp_mapping)); - octets_clean(dst->octets); - dst->octets = octets_init(octet_of_phy(dst->max_port)); -} - -static struct pp_qos_dev *init_clone(struct pp_qos_dev *qdev) -{ - struct pp_qos_dev *clone; - - clone = _qos_init(qdev->max_port); - clone->portsphys = free_ports_phys_init(clone->reserved_ports, qdev->max_port, qdev->reserved_ports, MAX_PORTS); - - - return clone; -} - -void basic_tests(void) -{ - struct pp_qos_dev *qdev; - struct pp_qos_dev *clone; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - QOS_LOG_INFO("starting basic tests :)\n"); - clone = init_clone(qdev); - QOS_ASSERT(clone, "Could not create clone\n"); - - - test_modify_used_status(qdev); - test_phy_allocation_not_full_octet(qdev); - test_phy_allocation_full_octet(qdev); - test_phy_allocation_full_octet_2(qdev); - test_internal_scheduler(qdev); - - reset_qos_dev(qdev, clone); - _qos_clean(clone); - QOS_LOG_INFO("basic tests completed successfully :)\n"); -} - -void advance_tests(void) -{ - struct pp_qos_dev *qdev; - struct pp_qos_dev *clone; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - QOS_LOG_INFO("starting advance tests :)\n"); - if (qdev->max_port < 15) { - QOS_LOG_ERR("Advance test requires that max port will be at least 15 !!!!\n"); - return; - } - clone = init_clone(qdev); - QOS_ASSERT(clone, "Could not create clone\n"); - - test_ports(qdev); - reset_qos_dev(qdev, clone); - - test_queues1(qdev); - reset_qos_dev(qdev, clone); - - test_queues2(qdev); - reset_qos_dev(qdev, clone); - - test_queues3(qdev); - reset_qos_dev(qdev, clone); - - reposition_internal_test(qdev); - reset_qos_dev(qdev, clone); - - test_shared_group(qdev); - reset_qos_dev(qdev, clone); - - _qos_clean(clone); - QOS_LOG_INFO("advance tests completed successfully :)\n"); -} - -void tests(void) -{ - /* - * An old test that is not working but want to keep. - * So compiler will not shout of unused function i - */ - struct pp_qos_dev *qdev; - if (0) - test_move_nodes(qdev); - - basic_tests(); - advance_tests(); - QOS_LOG_INFO("all tests completed successfully :)\n"); -} - -#define RING_ADDRESS 0x247000 -#define RING_ADDRESS_0 0x240000 -#define RING_ADDRESS_7 0x240700 -#define RING_ADDRESS_26 0x241A00 -#define RING_ADDRESS_89 0x245900 - -#if 0 -void falcon_test(void) -{ - struct pp_qos_dev *qdev; - unsigned int p89; - unsigned int p26; - unsigned int p7; - unsigned int p0; - unsigned int q[10]; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[0] = 1; - qdev->reserved_ports[26] = 1; - qdev->reserved_ports[89] = 1; - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x400; - - QOS_ASSERT(pp_qos_port_allocate(qdev, 89, &p89) == 0, "Could not allocate port\n"); - confp.ring_address = (void *)RING_ADDRESS_89; - QOS_ASSERT(pp_qos_port_set(qdev, p89, &confp) == 0, "Could not set port\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[0]) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = p89; - QOS_ASSERT(pp_qos_queue_set(qdev, q[0], &confq) == 0, "Setting failed\n"); - - QOS_ASSERT(pp_qos_port_allocate(qdev, 0, &p0) == 0, "Could not allocate port\n"); - confp.ring_address = (void *)RING_ADDRESS_0; - QOS_ASSERT(pp_qos_port_set(qdev, p0, &confp) == 0, "Could not set port\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[1]) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = p0; - QOS_ASSERT(pp_qos_queue_set(qdev, q[1], &confq) == 0, "Setting failed"); - - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p7) == 0, "Could not allocate port\n"); - confp.ring_address = (void *)RING_ADDRESS_7; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[2]) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = p7; - QOS_ASSERT(pp_qos_queue_set(qdev, q[2], &confq) == 0, "Setting failed\n"); - - QOS_ASSERT(pp_qos_port_allocate(qdev, 26, &p26) == 0, "Could not allocate port\n"); - confp.ring_address = (void *)RING_ADDRESS_26; - QOS_ASSERT(pp_qos_port_set(qdev, p26, &confp) == 0, "Could not set port\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[3]) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = p26; - QOS_ASSERT(pp_qos_queue_set(qdev, q[3], &confq) == 0, "Setting failed"); - - QOS_ASSERT(pp_qos_queue_remove(qdev, q[2]) == 0, "removing failed\n"); -} -#endif - -#if 0 -void falcon_test(void) -{ - unsigned int i; - void *address; - struct pp_qos_dev *qdev; - unsigned int p[3]; - unsigned int q[10]; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - unsigned int rlms[] = {14, 74, 30, 87, 235, 42, 242, 190, 119, 103}; - unsigned int ring_address[] = {RING_ADDRESS_0, RING_ADDRESS_7, RING_ADDRESS_26}; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[0] = 1; - qdev->reserved_ports[26] = 1; - - /* Hacking rlms array to give rlm that the slim driver currently uses */ - for (i = 0; i < sizeof(rlms) / sizeof(rlms[0]); ++i) { - qdev->rlms->data[NUM_OF_QUEUES - 1 - i] = rlms[i]; - qdev->rlms->data[NUM_OF_QUEUES - 1 - rlms[i]] = i; - } - - /* Configure ports 0, 7, 26 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 0, &p[0]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p[1]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 26, &p[2]) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - for (i = 0 ; i < 3; ++i) { - confp.ring_address = (void *)(ring_address[i]); - if (i == 0) - confp.credit = 2; - else - confp.credit = 8; - QOS_ASSERT(pp_qos_port_set(qdev, p[i], &confp) == 0, "Could not set port\n"); - } - - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x400; - for (i = 0; i < 10; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, q + i) == 0, "Could not allocate queue\n"); - if (i < 4) - confq.queue_child_prop.parent = p[0]; - else if (i < 7) - confq.queue_child_prop.parent = p[1]; - else - confq.queue_child_prop.parent = p[2]; - - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - } - - QOS_LOG_INFO("Falcon test completed successfully :)\n"); -} -#endif - -#if 1 -void falcon_test(void) -{ - unsigned int i; - struct pp_qos_dev *qdev; - unsigned int p[3]; - unsigned int p89; - unsigned int q[10]; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - struct pp_qos_node_info info; - unsigned int rlms[] = {14, 74, 30, 87, 235, 42, 242, 190, 119, 103}; - unsigned int ring_address[] = {RING_ADDRESS_0, RING_ADDRESS_7, RING_ADDRESS_26, RING_ADDRESS_89}; - - QOS_LOG_INFO("Falcon move test started\n"); - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[0] = 1; - qdev->reserved_ports[26] = 1; - qdev->reserved_ports[89] = 1; - - /* Hacking rlms array to give rlm that the slim driver currently uses */ - for (i = 0; i < sizeof(rlms) / sizeof(rlms[0]); ++i) { - qdev->rlms->data[NUM_OF_QUEUES - 1 - i] = rlms[i]; - qdev->rlms->data[NUM_OF_QUEUES - 1 - rlms[i]] = i; - } - - /* Configure ports 0, 7, 26 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 0, &p[0]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p[1]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 26, &p[2]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 89, &p89) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - for (i = 0 ; i < 3; ++i) { - confp.ring_address = (void *)(uintptr_t)(ring_address[i]); - if (i == 0) - confp.credit = 2; - else - confp.credit = 8; - QOS_ASSERT(pp_qos_port_set(qdev, p[i], &confp) == 0, "Could not set port\n"); - } - - QOS_ASSERT(pp_qos_port_set(qdev, p89, &confp) == 0, "Could not set port\n"); - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x400; - confq.queue_child_prop.parent = p89; - for (i = 0; i < 10; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, q + i) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - } - - for (i = 0; i < 10; ++i) { - if (i < 4) - confq.queue_child_prop.parent = p[0]; - else if (i < 7) - confq.queue_child_prop.parent = p[1]; - else - confq.queue_child_prop.parent = p[2]; - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - } - - check_consistency_with_resources(qdev); - - QOS_ASSERT(pp_qos_get_node_info(qdev, p89, &info) == 0, "Could not get node info\n"); - for (i = 0; i < 3; ++i) - QOS_ASSERT(pp_qos_get_node_info(qdev, p[i], &info) == 0, "Could not get node info\n"); - - for (i = 0; i < 10; ++i) - QOS_ASSERT(pp_qos_get_node_info(qdev, q[i], &info) == 0, "Could not get node info\n"); - - QOS_LOG_INFO("Falcon move test completed successfully :)\n"); -} -#endif - -#if 0 -void falcon_test(void) -{ - unsigned int i; - struct pp_qos_dev *qdev; - unsigned int p26; - unsigned int q1; - unsigned int q2; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - unsigned int rlms[] = {14, 74, 30, 87, 235, 42, 242, 190, 119, 103}; - unsigned int ring_address[] = {RING_ADDRESS_0, RING_ADDRESS_26}; - - QOS_LOG_INFO("Falcon test started\n"); - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[26] = 1; - - /* Hacking rlms array to give rlm that the slim driver currently uses */ - for (i = 0; i < sizeof(rlms) / sizeof(rlms[0]); ++i) { - qdev->rlms->data[NUM_OF_QUEUES - 1 - i] = rlms[i]; - qdev->rlms->data[NUM_OF_QUEUES - 1 - rlms[i]] = i; - } - - /* Configure port 26 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 26, &p26) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - confp.ring_address = (void *)(RING_ADDRESS_26); - confp.credit = 8; - QOS_ASSERT(pp_qos_port_set(qdev, p26, &confp) == 0, "Could not set port\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p26; - confq.queue_wred_max_allowed = 0x400; - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q1) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q1, &confq) == 0, "Setting queue fail\n"); - QOS_ASSERT(pp_qos_queue_remove(qdev, q1) == 0, "Remove queue failed\n"); - - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q2) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q2, &confq) == 0, "Setting queue fail\n"); - QOS_LOG_INFO("Falcon test completed successfully :)\n"); -} -#endif -#if 0 -/* - * p(0) -> 14 - * p(7) -> s(a) -> s(b) -> s(c) -> s(d) -> s(e) -> q(235) - */ -void falcon_test(void) -{ - unsigned int i; - struct pp_qos_dev *qdev; - unsigned int p1; - unsigned int p7; - unsigned int s[5]; - unsigned int q; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - struct pp_qos_sched_conf confs; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - - /* add port 0 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 1, &p1) == 0, "Could not allocate port 0\n"); - confp.credit = 2; - confp.ring_address = (void *)RING_ADDRESS_0; - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port 0\n"); - - /* add port 7 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p7) == 0, "Could not allocate port 0\n"); - confp.credit = 8; - confp.ring_address = (void *)RING_ADDRESS_7; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port 7\n"); - - /* Allocate 5 scheduler each is a child of its predecessor */ - pp_qos_sched_conf_set_default(&confs); - for (i = 0; i < 5; ++i) { - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s[i]) == 0, "Could not allocate sched\n"); - if (i == 0) - confs.sched_child_prop.parent = p7; - else - confs.sched_child_prop.parent = s[i - 1]; - QOS_ASSERT(pp_qos_sched_set(qdev, s[i], &confs) == 0, "Could not set sched\n"); - } - - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x400; - - /* Add q */ - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q) == 0, "Could not allocate queue 235\n"); - confq.queue_child_prop.parent = s[4]; - QOS_ASSERT(pp_qos_queue_set(qdev, q, &confq) == 0, "Could not set queue 235\n"); - - - check_consistency_with_resources(qdev); - QOS_LOG_INFO("Deep configuration completed\n"); - - confs.sched_child_prop.parent = p7; - QOS_ASSERT(pp_qos_sched_set(qdev, s[3], &confs) == 0, "Could not set sched\n"); - check_consistency_with_resources(qdev); -} -#endif - -#if 0 -/* - * p(0) -> q(14) - * p(7) -> all other queues - */ -static unsigned int q[256]; -void falcon_test(void) -{ - unsigned int i; - struct pp_qos_dev *qdev; - unsigned int p7; - unsigned int p0; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; -#if 0 - unsigned int q14; - unsigned int rlms[] = {14}; -#endif - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[0] = 1; - qdev->reserved_ports[26] = 1; - -#if 0 - /* Hacking rlms array to give rlm that the slim driver currently uses */ - for (i = 0; i < sizeof(rlms) / sizeof(rlms[0]); ++i) { - qdev->rlms->data[NUM_OF_QUEUES - 1 - i] = rlms[i]; - qdev->rlms->data[NUM_OF_QUEUES - 1 - rlms[i]] = i; - } -#endif - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - - /* add port 0 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 0, &p0) == 0, "Could not allocate port 0\n"); - confp.credit = 2; - confp.ring_address = (void *)RING_ADDRESS_0; - QOS_ASSERT(pp_qos_port_set(qdev, p0, &confp) == 0, "Could not set port 0\n"); - - /* add port 7 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p7) == 0, "Could not allocate port 0\n"); - confp.credit = 8; - confp.ring_address = (void *)RING_ADDRESS_7; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port 7\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x200; - -#if 0 - /* Add q14 under port 0 */ - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q14) == 0, "Could not allocate queuei 14\n"); - confq.queue_child_prop.parent = p0; - QOS_ASSERT(pp_qos_queue_set(qdev, q14, &confq) == 0, "Could not set queue 14\n"); -#endif - - /* Add other 255 queues under p7 */ - confq.queue_child_prop.parent = p7; - for (i = 0; i < 256 ; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q[i]) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Could not set queue\n"); - } - - QOS_LOG_INFO("All queues test configuration completed\n"); -} -#endif - -#if 0 -void falcon_test(void) -{ - unsigned int i; - struct pp_qos_dev *qdev; - unsigned int p[3]; - unsigned int q[10]; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - unsigned int rlms[] = {14, 74, 30, 87, 235, 42, 242, 190, 119, 103}; - unsigned int ring_address[] = {RING_ADDRESS_0, RING_ADDRESS_7, RING_ADDRESS_26}; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - qdev->reserved_ports[0] = 1; - qdev->reserved_ports[26] = 1; - - /* Hacking - * rlms - * array - * to - * give - * rlm - * that - * the - * slim - * driver - * currently - * uses - * */ - for (i = 0; i < sizeof(rlms) / sizeof(rlms[0]); ++i) { - qdev->rlms->data[NUM_OF_QUEUES - 1 - i] = rlms[i]; - qdev->rlms->data[NUM_OF_QUEUES - 1 - rlms[i]] = i; - } - - /* Configure - * ports - * 0, - * 7, - * 26 - * */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 0, &p[0]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p[1]) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_port_allocate(qdev, 26, &p[2]) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - for (i = 0 ; i < 3; ++i) { - confp.ring_address = (void *)(uintptr_t)(ring_address[i]); - if (i == 0) - confp.credit = 2; - else - confp.credit = 8; - confp.common_prop.bandwidth_limit = 0; - if (i==1) - { - confp.common_prop.bandwidth_limit = 1; - } - - QOS_ASSERT(pp_qos_port_set(qdev, p[i], &confp) == 0, "Could not set port\n"); - } - - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 0x400; - for (i = 0; i < 10; ++i) { - QOS_ASSERT(pp_qos_queue_allocate(qdev, q + i) == 0, "Could not allocate queue\n"); - if (i < 4) - confq.queue_child_prop.parent = p[0]; - else if (i < 7) - confq.queue_child_prop.parent = p[1]; - else - confq.queue_child_prop.parent = p[2]; - - QOS_ASSERT(pp_qos_queue_set(qdev, q[i], &confq) == 0, "Setting failed on %d iteration\n", i); - } - - QOS_LOG_INFO("Falcon test completed successfully :)\n"); -} -#endif - - -#if 1 -void stat_test(void) -{ - struct pp_qos_dev *qdev; - unsigned int p; - unsigned int q1; - unsigned int q2; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - struct pp_qos_queue_stat qstat; - struct pp_qos_port_stat pstat; - - QOS_LOG_INFO("statistics test started\n"); - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - QOS_ASSERT(pp_qos_port_allocate(qdev, 1, &p) == 0, "Could not allocate port\n"); - pp_qos_port_conf_set_default(&confp); - - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - confp.ring_address = (void *)RING_ADDRESS; - QOS_ASSERT(pp_qos_port_set(qdev, p, &confp) == 0, "Could not set port\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_wred_max_allowed = 1000; - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q1) == 0, "Could not allocate queue\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q2) == 0, "Could not allocate queue\n"); - confq.queue_child_prop.parent = p; - QOS_ASSERT(pp_qos_queue_set(qdev, q1, &confq) == 0, "Could not set queue\n"); - QOS_ASSERT(pp_qos_queue_set(qdev, q2, &confq) == 0, "Could not set queue\n"); - - memset(&pstat, 0, sizeof(pstat)); - QOS_ASSERT(pp_qos_port_stat_get(qdev, p, &pstat) == 0, "Could not get port statistics\n"); - - memset(&qstat, 0, sizeof(qstat)); - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q1, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 0 && - qstat.queue_packets_occupancy == 0 && - qstat.queue_bytes_occupancy == 0 && - qstat.total_packets_accepted == 0 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 0 && - qstat.total_bytes_dropped == 0, "Some field of q1 stats is not 0\n"); - - memset(&qstat, 0, sizeof(qstat)); - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q2, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 0 && - qstat.queue_packets_occupancy == 0 && - qstat.queue_bytes_occupancy == 0 && - qstat.total_packets_accepted == 0 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 0 && - qstat.total_bytes_dropped == 0, "Some field of q2 stats is not 0\n"); - - memset(&pstat, 0, sizeof(pstat)); - QOS_ASSERT(pp_qos_port_stat_get(qdev, p, &pstat) == 0, "Could not get port statistics\n"); - QOS_ASSERT( - pstat.reset == 0 && - pstat.total_green_bytes == 0 && - pstat.total_yellow_bytes == 0, "Some field of p stats is not 0\n"); - - create_push_desc_cmd(qdev, 0, 128, 1, 0x600000); - create_push_desc_cmd(qdev, 0, 256, 2, 0x600000); - create_push_desc_cmd(qdev, 1, 100, 1, 0x600000); - create_push_desc_cmd(qdev, 1, 200, 2, 0x600000); - update_cmd_id(&qdev->drvcmds); - transmit_cmds(qdev); - - memset(&qstat, 0, sizeof(qstat)); - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q1, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 0 && - qstat.queue_packets_occupancy == 2 && - qstat.queue_bytes_occupancy == 384 && - qstat.total_packets_accepted == 2 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 384 && - qstat.total_bytes_dropped == 0, "Some fields of q1 stats are not expected\n"); - - memset(&qstat, 0, sizeof(qstat)); - qstat.reset = 1; - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q2, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 1 && - qstat.queue_packets_occupancy == 2 && - qstat.queue_bytes_occupancy == 300 && - qstat.total_packets_accepted == 2 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 300 && - qstat.total_bytes_dropped == 0, "Some fields of q2 are not expected\n"); - - memset(&pstat, 0, sizeof(pstat)); - QOS_ASSERT(pp_qos_port_stat_get(qdev, p, &pstat) == 0, "Could not get port statistics\n"); - QOS_ASSERT( - pstat.reset == 0 && - pstat.total_green_bytes == 228 && - pstat.total_yellow_bytes == 456, "Some fields of p stats are not expected\n"); - - create_push_desc_cmd(qdev, 0, 100, 1, 0x600000); - create_push_desc_cmd(qdev, 1, 300, 1, 0x600000); - - memset(&qstat, 0, sizeof(qstat)); - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q1, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 0 && - qstat.queue_packets_occupancy == 3 && - qstat.queue_bytes_occupancy == 484 && - qstat.total_packets_accepted == 3 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 484 && - qstat.total_bytes_dropped == 0, "Some field of q1 stats are not expected\n"); - - QOS_ASSERT(pp_qos_queue_stat_get(qdev, q2, &qstat) == 0, "Could not get queue statistics\n"); - QOS_ASSERT( - qstat.reset == 0 && - qstat.queue_packets_occupancy == 3 && - qstat.queue_bytes_occupancy == 600 && - qstat.total_packets_accepted == 1 && - qstat.total_packets_dropped == 0 && - qstat.total_packets_red_dropped == 0 && - qstat.total_bytes_accepted == 300 && - qstat.total_bytes_dropped == 0, "Some field of q2 stats is not 0\n"); - - memset(&pstat, 0, sizeof(pstat)); - pstat.reset = 1; - QOS_ASSERT(pp_qos_port_stat_get(qdev, p, &pstat) == 0, "Could not get port statistics\n"); - QOS_ASSERT( - pstat.reset == 1 && - pstat.total_green_bytes == 628 && - pstat.total_yellow_bytes == 456, "Some fields of p stats are not expected\n"); - - - create_push_desc_cmd(qdev, 0, 100, 2, 0x600000); - memset(&pstat, 0, sizeof(pstat)); - QOS_ASSERT(pp_qos_port_stat_get(qdev, p, &pstat) == 0, "Could not get port statistics\n"); - QOS_ASSERT( - pstat.reset == 0 && - pstat.total_green_bytes == 0 && - pstat.total_yellow_bytes == 100, "Some fields of p stats are not expected\n"); - - QOS_LOG_INFO("statistics test completed successfully :)\n"); - -} -#endif - -#if 0 -void falcon_test(void) -{ - struct pp_qos_dev *qdev; - unsigned int p; - unsigned int s; - unsigned int q; - struct pp_qos_queue_info qinfo; - struct pp_qos_sched_info sinfo; - struct pp_qos_port_info pinfo; - int rc; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - QOS_ASSERT(pp_qos_port_allocate(qdev, ALLOC_PORT_ID, &p) == 0, "Could not allocate port\n"); - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s) == 0, "Could not allocate sched\n"); - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q) == 0, "Could not allocate queue 0\n"); - rc = pp_qos_port_info_get(qdev, p, &pinfo); - rc = pp_qos_sched_info_get(qdev, s, &sinfo); - rc = pp_qos_queue_info_get(qdev, q, &qinfo); -} -#endif - -#if 0 -void falcon_test(void) -{ - struct pp_qos_dev *qdev; - unsigned int p7; - unsigned int q0; - unsigned int q1; - struct pp_qos_port_conf confp; - struct pp_qos_queue_conf confq; - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - - /* add port 7 */ - QOS_ASSERT(pp_qos_port_allocate(qdev, 7, &p7) == 0, "Could not allocate port 7\n"); - confp.credit = 8; - confp.ring_address = (void *)RING_ADDRESS_7; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port 7\n"); - QOS_ASSERT(pp_qos_port_suspend(qdev, p7) == 0, "Could not suspend port 7\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p7; - confq.queue_wred_min_guaranteed = 0; - confq.queue_wred_max_allowed = 25; - confq.wred_enable = 1; - confq.wred_fixed_drop_prob_enable = 1; - - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q0) == 0, "Could not allocate queue 0\n"); - confq.queue_wred_min_avg_green = 5; - confq.queue_wred_max_avg_green = 15; - confq.queue_wred_fixed_drop_prob_green = 20; - confq.queue_wred_min_avg_yellow = 10; - confq.queue_wred_max_avg_yellow = 20; - confq.queue_wred_fixed_drop_prob_yellow = 80; - QOS_ASSERT(pp_qos_queue_set(qdev, q0, &confq) == 0, "Could not set queue 0\n"); - - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q1) == 0, "Could not allocate queue 1\n"); - confq.queue_wred_min_avg_green = 12; - confq.queue_wred_max_avg_green = 22; - confq.queue_wred_fixed_drop_prob_green = 0; - confq.queue_wred_min_avg_yellow = 15; - confq.queue_wred_max_avg_yellow = 25; - confq.queue_wred_fixed_drop_prob_yellow = 100; - QOS_ASSERT(pp_qos_queue_set(qdev, q1, &confq) == 0, "Could not set queue 1\n"); - - QOS_LOG_INFO("WRED configuration completed\n"); -} -#endif - -void reposition_test(void) -{ - unsigned int s[5]; - unsigned int q; - unsigned int p1; - unsigned int p7; - int tmp; - unsigned int i; - struct pp_qos_port_conf confp; - struct pp_qos_sched_conf confs; - struct pp_qos_queue_conf confq; - struct pp_qos_dev *qdev; - struct pp_qos_node_info info; - - QOS_LOG_INFO("reposition test started\n"); - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - tmp = pp_qos_port_allocate(qdev, 1, &p1); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - tmp = pp_qos_port_allocate(qdev, 7, &p7); - QOS_ASSERT(tmp == 0, "could not allocate qos port\n"); - - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_size = 1; - - confp.ring_address = (void *)950000; - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - - confp.ring_address = (void *)950600; - QOS_ASSERT(pp_qos_port_set(qdev, p7, &confp) == 0, "Could not set port\n"); - - pp_qos_sched_conf_set_default(&confs); - for (i = 0; i < 5; ++i) { - QOS_ASSERT(pp_qos_sched_allocate(qdev, &s[i]) == 0, "Could not allocate sched\n"); - if (i == 0) - confs.sched_child_prop.parent = p1; - else - confs.sched_child_prop.parent = s[i - 1]; - QOS_ASSERT(pp_qos_sched_set(qdev, s[i], &confs) == 0, "Could not set sched\n"); - } - QOS_ASSERT(pp_qos_queue_allocate(qdev, &q) == 0, "Could not allocate queue\n"); - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = s[4]; - QOS_ASSERT(pp_qos_queue_set(qdev, q, &confq) == 0, "Could not set queue\n"); - - confs.sched_child_prop.parent = p1; - QOS_ASSERT(pp_qos_sched_set(qdev, s[3], &confs) == 0, "Could not set sched\n"); - - confs.sched_child_prop.parent = p7; - QOS_ASSERT(pp_qos_sched_set(qdev, s[4], &confs) == 0, "Could not set sched\n"); - check_consistency_with_resources(qdev); - - QOS_ASSERT(pp_qos_get_node_info(qdev, p1, &info) == 0, "Could not get node info\n"); - QOS_ASSERT(pp_qos_get_node_info(qdev, p7, &info) == 0, "Could not get node info\n"); - QOS_ASSERT(pp_qos_get_node_info(qdev, q, &info) == 0, "Could not get node info\n"); - for (i = 0; i < 5; ++i) - QOS_ASSERT(pp_qos_get_node_info(qdev, s[i], &info) == 0, "Could not get node info\n"); - - QOS_LOG_INFO("reposition test completed successfully :)\n"); -} - -void info_test(void) -{ - struct pp_qos_queue_conf confq; - struct pp_qos_port_conf confp; - struct pp_qos_dev *qdev; - unsigned int p1; - unsigned int q[100]; - unsigned int i; - struct pp_qos_node_info info; - - QOS_LOG_INFO("info test started\n"); - - qdev = test_open_and_init_instance(0); - if (!qdev) - return; - - /* Allocate port 1 */ - pp_qos_port_conf_set_default(&confp); - confp.port_parent_prop.arbitration = PP_QOS_ARBITRATION_WRR; - confp.ring_address = (void *)1; - confp.ring_size = 1; - pp_qos_port_allocate(qdev, 1, &p1); - QOS_ASSERT(pp_qos_port_set(qdev, p1, &confp) == 0, "Could not set port\n"); - check_consistency_with_resources(qdev); - QOS_ASSERT(pp_qos_get_node_info(qdev, p1, &info) == 0, "Could not get node info\n"); - - pp_qos_queue_conf_set_default(&confq); - confq.queue_child_prop.parent = p1; - //confq.common_prop.bandwidth_limit = 77; - /* Allocate 8 queues */ - for (i = 0; i < 8; ++ i) { - pp_qos_queue_allocate(qdev, &q[i]); - confq.queue_wred_max_allowed = i; - pp_qos_queue_set(qdev, q[i], &confq); - } - QOS_ASSERT(pp_qos_get_node_info(qdev, p1, &info) == 0, "Could not get node info\n"); - QOS_ASSERT(info.type == PPV4_QOS_NODE_TYPE_PORT && - info.children[0].phy == 128 && - info.children[1].phy == 129 && - info.children[2].phy == 130 && - info.children[3].phy == 131 && - info.children[4].phy == 132 && - info.children[5].phy == 133 && - info.children[6].phy == 134 && - info.children[7].phy == 135 && - info.children[0].id == 1 && - info.children[1].id == 2 && - info.children[2].id == 3 && - info.children[3].id == 4 && - info.children[4].id == 5 && - info.children[5].id == 6 && - info.children[6].id == 7 && - info.children[7].id == 8 && - info.is_suspended == 0 && - info.is_internal == 0 && - info.bw_limit == 0 && - (info.preds[0].phy == info.preds[0].id && - info.preds[1].phy == info.preds[1].id && - info.preds[2].phy == info.preds[2].id && - info.preds[3].phy == info.preds[3].id && - info.preds[4].phy == info.preds[4].id && - info.preds[5].phy == info.preds[5].id && - info.port == info.queue_physical_id), - "Unexpected value from node get info\n"); - - QOS_ASSERT(pp_qos_get_node_info(qdev, q[7], &info) == 0, "Could not get node info\n"); - QOS_ASSERT(info.type == PPV4_QOS_NODE_TYPE_QUEUE && - info.children[0].phy == PPV4_QOS_INVALID && - info.children[1].phy == PPV4_QOS_INVALID && - info.children[2].phy == PPV4_QOS_INVALID && - info.children[3].phy == PPV4_QOS_INVALID && - info.children[4].phy == PPV4_QOS_INVALID && - info.children[5].phy == PPV4_QOS_INVALID && - info.children[6].phy == PPV4_QOS_INVALID && - info.children[7].phy == PPV4_QOS_INVALID && - info.children[0].id == PPV4_QOS_INVALID && - info.children[1].id == PPV4_QOS_INVALID && - info.children[2].id == PPV4_QOS_INVALID && - info.children[3].id == PPV4_QOS_INVALID && - info.children[4].id == PPV4_QOS_INVALID && - info.children[5].id == PPV4_QOS_INVALID && - info.children[6].id == PPV4_QOS_INVALID && - info.children[7].id == PPV4_QOS_INVALID && - info.is_suspended == 0 && - info.is_internal == 0 && - info.bw_limit == 0 && - info.preds[0].phy == 1 && - info.preds[0].id == 0 && - info.preds[1].phy == info.preds[1].id && - info.preds[2].phy == info.preds[2].id && - info.preds[3].phy == info.preds[3].id && - info.preds[4].phy == info.preds[4].id && - info.preds[5].phy == info.preds[5].id && - info.port == 1 && - info.queue_physical_id == 7, - "Unexpected value from node get info\n"); - - /* Allocate 64 more queues */ - for (i = 8; i < 100; ++i) { - pp_qos_queue_allocate(qdev, &q[i]); - pp_qos_queue_set(qdev, q[i], &confq); - } - QOS_ASSERT(pp_qos_get_node_info(qdev, q[7], &info) == 0, "Could not get node info\n"); - QOS_ASSERT(info.type == PPV4_QOS_NODE_TYPE_QUEUE && - info.children[0].phy == PPV4_QOS_INVALID && - info.children[1].phy == PPV4_QOS_INVALID && - info.children[2].phy == PPV4_QOS_INVALID && - info.children[3].phy == PPV4_QOS_INVALID && - info.children[4].phy == PPV4_QOS_INVALID && - info.children[5].phy == PPV4_QOS_INVALID && - info.children[6].phy == PPV4_QOS_INVALID && - info.children[7].phy == PPV4_QOS_INVALID && - info.children[0].id == PPV4_QOS_INVALID && - info.children[1].id == PPV4_QOS_INVALID && - info.children[2].id == PPV4_QOS_INVALID && - info.children[3].id == PPV4_QOS_INVALID && - info.children[4].id == PPV4_QOS_INVALID && - info.children[5].id == PPV4_QOS_INVALID && - info.children[6].id == PPV4_QOS_INVALID && - info.children[7].id == PPV4_QOS_INVALID && - info.is_suspended == 0 && - info.is_internal == 0 && - info.bw_limit == 0 && - info.preds[0].phy == 135 && - info.preds[0].id == 66 && - info.preds[1].phy == 1 && - info.preds[1].id == 0 && - info.preds[2].phy == info.preds[2].id && - info.preds[3].phy == info.preds[3].id && - info.preds[4].phy == info.preds[4].id && - info.preds[5].phy == info.preds[5].id && - info.port == 1 && - info.queue_physical_id == 7, - "Unexpected value from node get info\n"); - - QOS_ASSERT(pp_qos_get_node_info(qdev, 66, &info) == 0, "Could not get node info\n"); - QOS_ASSERT(info.type == PPV4_QOS_NODE_TYPE_SCHED && - info.children[0].phy == 192 && - info.children[1].phy == 193 && - info.children[2].phy == 194 && - info.children[3].phy == 195 && - info.children[4].phy == 196 && - info.children[5].phy == 197 && - info.children[6].phy == 198 && - info.children[7].phy == 199 && - info.children[0].id == 8 && - info.children[1].id == 65 && - info.children[2].id == 67 && - info.children[3].id == 68 && - info.children[4].id == 69 && - info.children[5].id == 70 && - info.children[6].id == 71 && - info.children[7].id == 72 && - info.is_suspended == 0 && - info.is_internal == 1 && - info.bw_limit == 0 && - info.preds[0].phy == 1 && - info.preds[0].id == 0 && - info.preds[1].phy == info.preds[1].id && - info.preds[2].phy == info.preds[2].id && - info.preds[3].phy == info.preds[3].id && - info.preds[4].phy == info.preds[4].id && - info.preds[5].phy == info.preds[5].id && - info.port == PPV4_QOS_INVALID && - info.queue_physical_id == PPV4_QOS_INVALID, - "Unexpected value from node get info\n"); - check_consistency_with_resources(qdev); - QOS_LOG_INFO("info test completed successfully :)\n"); -} - -void load_fw_test(void) -{ - test_open_and_init_instance(0); -} - -#endif diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.c b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.c index e342db324..f6577c0f0 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.c +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.c @@ -149,6 +149,7 @@ STATIC_UNLESS_TEST void debug_verify_octet_usage(struct pp_octets *octets, struct list_head *list; struct list_head *pos; unsigned int tmp; + int found; tmp = octet_get_use_count(octets, octet); QOS_ASSERT(tmp == usage, "Octet %u count is %u and not %u\n", octet, @@ -156,14 +157,18 @@ STATIC_UNLESS_TEST void debug_verify_octet_usage(struct pp_octets *octets, list = &(octets->info[octet].list); if (octet > octets->last_port_octet) { + found = 0; for (pos = list->next; pos != list; pos = pos->next) { if (pos >= octets->lists && pos <= octets->lists + 8) { tmp = (pos - octets->lists); QOS_ASSERT(tmp == usage, "Octet is on list %u but should be on %u\n", tmp, usage); + found = 1; + break; } } + QOS_ASSERT(found, "Did not find list of octet %u\n", octet); } else { QOS_ASSERT(list_empty(list), "Octet %u is on a list though its a port octet\n", @@ -1422,12 +1427,13 @@ fail: void _qos_clean(struct pp_qos_dev *qdev) { if (qdev) { + pp_pool_clean(qdev->portsphys); clean_fwdata_internals(qdev); cmd_queue_clean(qdev->drvcmds.pendq); cmd_queue_clean(qdev->drvcmds.cmdq); pp_queue_clean(qdev->queue); pp_mapping_clean(qdev->mapping); - pp_pool_clean(qdev->portsphys); + pp_pool_clean(qdev->rlms); pp_pool_clean(qdev->ids); pp_nodes_clean(qdev->nodes); octets_clean(qdev->octets); @@ -1890,21 +1896,52 @@ static int parent_cfg_valid( const struct pp_qos_dev *qdev, const struct qos_node *node) { - unsigned int tmp; + unsigned int first; + unsigned int num; + unsigned int i; + struct qos_node *cur; + unsigned int priority; + unsigned int prev_priority; QOS_ASSERT(node_parent(node), "node is not a parent\n"); if (node->parent_prop.num_of_children > 8) { - QOS_LOG("node has %u children but max allowed is 8\n", + QOS_LOG_ERR("node has %u children but max allowed is 8\n", node->parent_prop.num_of_children); return 0; } - tmp = node->parent_prop.first_child_phy; - if ((node->parent_prop.num_of_children > 0) && - (tmp <= qdev->max_port || tmp > NUM_OF_NODES - 1)) { - QOS_LOG("node has %u children but first child %u is illegal\n", - node->parent_prop.num_of_children, tmp); + first = node->parent_prop.first_child_phy; + num = node->parent_prop.num_of_children; + if ((num > 0) && + (first <= qdev->max_port || first > NUM_OF_NODES - 1)) { + QOS_LOG_ERR("node has %u children but first child %u is illegal\n", + node->parent_prop.num_of_children, first); return 0; } + + if (num > 0 && + node->parent_prop.arbitration == PP_QOS_ARBITRATION_WSP) { + cur = get_node_from_phy(qdev->nodes, first); + prev_priority = 0; + for (i = 0; i < num; ++i) { + priority = cur->child_prop.priority; + if (priority > QOS_MAX_CHILD_PRIORITY) { + QOS_LOG_ERR("Child %u has illegal priority %u\n", + first + i, + priority); + return 0; + } + if ((i > 0) && (priority <= prev_priority)) { + QOS_LOG_ERR( + "Child %u has priority %u which is not bigger than previous child's priority %u\n", + first + i, + priority, + prev_priority); + return 0; + } + prev_priority = priority; + ++cur; + } + } return 1; } @@ -2516,3 +2553,72 @@ unsigned int phy_alloc_by_parent( return phy; } +int check_sync_with_fw(struct pp_qos_dev *qdev) +{ + unsigned int i; + unsigned int used; + //unsigned int res; + unsigned int id; + int rc; + const struct qos_node *node; + struct pp_pool *pool; + struct pp_qos_node_info info; + + rc = 0; + pool = pp_pool_init(NUM_OF_NODES, QOS_INVALID_ID); + if (pool == NULL) { + QOS_LOG_ERR("Can't create pool for firmware sync check\n"); + return -1; + } + + used = 0; + node = get_const_node_from_phy(qdev->nodes, 0); + for (i = 0; i < NUM_OF_NODES; ++i) { + if (node_used(node)) { + id = get_id_from_phy(qdev->mapping, i); + QOS_ASSERT(QOS_ID_VALID(id), + "Invalid id for phy %u\n", i); + pp_pool_put(pool, id); + ++used; + } + ++node; + } + +#if 0 + create_num_used_nodes_cmd(qdev, qdev->hwconf.fw_stat, &res); + QOS_ASSERT( + res == used, + "Driver's DB has %u used nodes, while firmware reports %u\n", + used, + res); +#endif + + id = pp_pool_get(pool); + while (QOS_ID_VALID(id)) { + if (pp_qos_get_node_info(qdev, id, &info)) { + QOS_LOG_ERR("Error info on %u\n", id); + rc = -1; + break; + } + id = pp_pool_get(pool); + } + + pp_pool_clean(pool); + return rc; +} + +/* Return 1 if device is not in assert and was initialized */ +int qos_device_ready(const struct pp_qos_dev *qdev) +{ + if (PP_QOS_DEVICE_IS_ASSERT(qdev)) { + QOS_LOG_CRIT("!!!!! Qos driver in unstable mode !!!!!\n"); + return 0; + } + + if (!qdev->initialized) { + QOS_LOG_ERR("Device was not initialized\n"); + return 0; + } + + return 1; +} diff --git a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.h b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.h index 5572940fb..790e0f099 100644 --- a/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.h +++ b/drivers/net/ethernet/lantiq/ppv4/qos/pp_qos_utils.h @@ -213,7 +213,7 @@ struct pp_qos_dev { LOCK lock; int initialized; unsigned int max_port; - unsigned int reserved_ports[MAX_PORTS]; + unsigned int reserved_ports[QOS_MAX_PORTS]; struct shared_bandwidth_group groups[QOS_MAX_SHARED_BW_GRP + 1]; struct pp_pool *ids; struct pp_pool *rlms; @@ -622,6 +622,7 @@ static inline unsigned int get_port(const struct pp_nodes *nodes, return get_phy_from_node(nodes, node); } +int qos_device_ready(const struct pp_qos_dev *qdev); void qos_module_init(void); void remove_qos_instance(unsigned int id); int _pp_qos_queue_block(struct pp_qos_dev *qdev, unsigned int id); @@ -638,6 +639,7 @@ void falcon_test(void); void simple_test(void); void stat_test(void); void info_test(void); +void wsp_test(void); void load_fw_test(void); void tests(void); void test_init_instance(struct pp_qos_dev *qdev); @@ -667,6 +669,7 @@ unsigned int get_children_bandwidth_share(const struct pp_qos_dev *qdev, const struct qos_node *parent); void transmit_cmds(struct pp_qos_dev *qdev); void update_cmd_id(struct driver_cmds *drvcmds); +int check_sync_with_fw(struct pp_qos_dev *qdev); #define STATIC_UNLESS_TEST #else #define STATIC_UNLESS_TEST static diff --git a/include/net/pp_qos_drv.h b/include/net/pp_qos_drv.h index 8b2985fef..bdd6ead87 100644 --- a/include/net/pp_qos_drv.h +++ b/include/net/pp_qos_drv.h @@ -843,8 +843,8 @@ struct pp_qos_init_param { unsigned int wred_total_avail_resources; unsigned int wred_p_const; unsigned int wred_max_q_size; - #define MAX_PORTS 128 - unsigned int reserved_ports[MAX_PORTS]; + #define QOS_MAX_PORTS 128 + unsigned int reserved_ports[QOS_MAX_PORTS]; }; -- GitLab