diff --git a/libqos/broadcom/src/bcm_qos_archer.c b/libqos/broadcom/src/bcm_qos_archer.c index 1e90eeb1b6f2b5614fbaf7b99092478da7ef5729..4041aeeb625187b0ade197d8a175d6ae3bd740b1 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 3957cabd1b941a1aa465adee6a474b4b797d4342..e0b2ffc581326eba6c92da1d1e31a5d5e0eb2954 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 919c2ad0dec80a992ad89fc14d6879dcfc6fdf95..76c3a9086a8794bb96336d344c887bf0855e5dea 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 a4bf8f3bf22e956f575bdf780ed9ce826c7fa529..0d8b3d11672fcfb392b257d22651201a3384cd06 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 5b5bd8ea29fc3f4302200cb0d163d59f44d4f502..40019745bb2e1d154f1a6ed62694682ff9489443 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 2bd0eb27436f48cd5361c9b7dcf0a8b8245910cb..ec8387134190cae16d850cbae9403582444bff8f 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 e5df0cd9a6424fd99ac87e7f0ccca7f048730cb8..c5ba0b1730073f8f0be0c4ceff361b627b12cdc6 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 };