From c6d9080e8c81f5533eb45afa1b4184732d20cd4b Mon Sep 17 00:00:00 2001 From: Amit Kumar <amit.kumar@iopsys.eu> Date: Thu, 9 Feb 2023 10:20:19 +0530 Subject: [PATCH] libqos: handliing to get num of queue --- libqos/broadcom/src/bcm_qos_archer.c | 6 ++++++ libqos/broadcom/src/bcm_qos_runner.c | 29 ++++++++++++++++++++++++++++ libqos/econet/src/ecnt_qos.c | 8 ++++++++ libqos/include/qos.h | 2 ++ libqos/linux/linux_qos.c | 12 ++++++++++++ libqos/src/qos.c | 8 ++++++++ libqos/test/test.c | 6 ++++++ 7 files changed, 71 insertions(+) diff --git a/libqos/broadcom/src/bcm_qos_archer.c b/libqos/broadcom/src/bcm_qos_archer.c index 1e90eeb1..4041aeeb 100644 --- a/libqos/broadcom/src/bcm_qos_archer.c +++ b/libqos/broadcom/src/bcm_qos_archer.c @@ -97,7 +97,13 @@ static int bcm_get_stats(const char *ifname, return ret; } +int archer_get_num_of_queue(const char *ifname) +{ + return 4; +} + const struct qos_ops bcm_rdpa_ops = { .ifname = "eth", .get_stats = bcm_get_stats, + .get_num_of_queue = archer_get_num_of_queue }; diff --git a/libqos/broadcom/src/bcm_qos_runner.c b/libqos/broadcom/src/bcm_qos_runner.c index 3957cabd..e0b2ffc5 100644 --- a/libqos/broadcom/src/bcm_qos_runner.c +++ b/libqos/broadcom/src/bcm_qos_runner.c @@ -289,9 +289,38 @@ static int bcm_get_stats(const char *ifname, return ret; } +static int runner_get_num_of_queue(const char *ifname) +{ + bdmf_object_handle owner; + rdpa_port_tm_cfg_t tm_cfg; + rdpa_ioctl_cmd_t pa = {0}; + int fd = -1; + char num_queues = 8; + int ret = -1; + + ret = get_tm_owner((char *)ifname, &owner); + if (ret == 0) { + ret = get_root_tm(owner, &tm_cfg); + if (ret == 0) { + + pa.mo = tm_cfg.sched; + pa.ptr = (bdmf_ptr)(unsigned long)&num_queues; + pa.cmd = RDPA_EGRESS_TM_NUM_QUEUES_GET; + fd = open(RDPA_USR_DEV_NAME, O_RDWR); + if (fd >= 0) { + ret = ioctl(fd, RDPA_EGRESS_TM_IOCTL, &pa); + close(fd); + } + } + } + + return num_queues; +} + const struct qos_ops bcm_rdpa_ops = { .ifname = "eth", .get_stats = bcm_get_stats, + .get_num_of_queue = runner_get_num_of_queue }; /** diff --git a/libqos/econet/src/ecnt_qos.c b/libqos/econet/src/ecnt_qos.c index 919c2ad0..76c3a908 100644 --- a/libqos/econet/src/ecnt_qos.c +++ b/libqos/econet/src/ecnt_qos.c @@ -220,17 +220,25 @@ static int ecnt_get_stats(const char *ifname, return read_from_syslog(queue_id, stats); } +int ecnt_get_num_of_queue(const char *ifname) +{ + return 8; +} + const struct qos_ops qos_ecnt_ops_eth = { .ifname = "eth", .get_stats = ecnt_get_stats, + .get_num_of_queue = ecnt_get_num_of_queue }; const struct qos_ops qos_ecnt_ops_nas = { .ifname = "nas", .get_stats = ecnt_get_stats, + .get_num_of_queue = ecnt_get_num_of_queue }; const struct qos_ops qos_ecnt_ops_ae_wan = { .ifname = "ae_wan", .get_stats = ecnt_get_stats, + .get_num_of_queue = ecnt_get_num_of_queue }; diff --git a/libqos/include/qos.h b/libqos/include/qos.h index a4bf8f3b..0d8b3d11 100644 --- a/libqos/include/qos.h +++ b/libqos/include/qos.h @@ -65,10 +65,12 @@ struct qos_ops { const char *ifname; int (*get_stats)(const char *ifname, int queue_id, struct qos_stats *stats, int *is_read_and_reset); + int (*get_num_of_queue)(); }; /* API list */ int qos_get_stats(const char *ifname, int queue_id, struct qos_stats *stats, int *is_read_and_reset); +int qos_get_num_of_queue(const char *ifname); #ifdef __cplusplus } diff --git a/libqos/linux/linux_qos.c b/libqos/linux/linux_qos.c index 5b5bd8ea..40019745 100644 --- a/libqos/linux/linux_qos.c +++ b/libqos/linux/linux_qos.c @@ -351,14 +351,26 @@ static int linux_get_stats(const char *ifname, return ret; } +/******************************************************* + * To get the number of qos queue for a linux device: + * return number of qos queue + ******************************************************* + */ +int linux_get_num_of_queue(const char *ifname) +{ + return 8; +} + #if defined(IOPSYS_LINUX) const struct qos_ops qos_linux_ops_eth = { .ifname = "lan", .get_stats = linux_get_stats, + .get_num_of_queue = linux_get_num_of_queue }; #elif defined(IPQ95XX) const struct qos_ops qos_linux_ops_eth = { .ifname = "eth", .get_stats = linux_get_stats, + .get_num_of_queue = linux_get_num_of_queue }; #endif diff --git a/libqos/src/qos.c b/libqos/src/qos.c index 2bd0eb27..ec838713 100644 --- a/libqos/src/qos.c +++ b/libqos/src/qos.c @@ -63,8 +63,16 @@ int qos_get_stats(const char *ifname, int queue_id, struct qos_stats *stats, int { const struct qos_ops *qos = get_qos_driver(ifname); + syslog(LOG_INFO, "Amit libqos Number of queue: %d",qos_get_num_of_queue(ifname)); if (qos && qos->get_stats) return qos->get_stats(ifname, queue_id, stats, is_read_and_reset); return -1; } + +int qos_get_num_of_queue(const char *ifname) +{ + const struct qos_ops *qos = qos_ops[0]; + + return qos->get_num_of_queue(ifname); +} diff --git a/libqos/test/test.c b/libqos/test/test.c index e5df0cd9..c5ba0b17 100644 --- a/libqos/test/test.c +++ b/libqos/test/test.c @@ -33,7 +33,13 @@ static int test_get_stats(const char *ifname, return 0; } +int test_get_num_of_queue(const char *ifname) +{ + return 8; +} + const struct qos_ops qos_test_ops = { .ifname = "eth", .get_stats = test_get_stats, + .get_num_of_queue = test_get_num_of_queue }; -- GitLab