Store the number of egress queues in the per-chip info structure and advertise it through ds->num_tx_queues, following the ksz driver (struct ksz_chip_data.num_tx_queues). The queue count is a per-chip hardware property, and this driver supports several chips of the rtl8367c family. All currently supported chips expose eight queues, but keeping the count in chip_info lets the QoS code that follows program the priority-to-queue map via the ieee8021q helpers for whatever queue count a chip carries, so the 802.1Q collapse is correct rather than hard-coded to eight. Signed-off-by: Oleksij Rempel Reviewed-by: Linus Walleij Reviewed-by: Luiz Angelo Daros de Luca --- Q: Linus: why is the queue count not in struct realtek_variant? A: The count is per chip, while realtek_variant is per subdriver, and rtl8365mb serves several chips. The QoS code added later in this series reads ds->num_tx_queues, as Linus suggested in his v1 review, so RTL8366RB can advertise its own count the same way. Changes in v2: - drop the num_tx_queues comment, which restated the assignment - keep the Reviewed-by tags: v2 only drops a comment --- drivers/net/dsa/realtek/rtl8365mb_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c index 1e6cdc61f6bd3b3f74e422dbbcfdcb67cc0532a7..f7960d94f1cd9f6a1982849a9e5a1b5d98880b4b 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_main.c +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c @@ -711,6 +711,7 @@ struct rtl8365mb_extint { * @extints: available external interfaces * @jam_table: chip-specific initialization jam table * @jam_size: size of the chip's jam table + * @num_tx_queues: number of egress queues exposed by the chip * * These data are specific to a given chip in the family of switches supported * by this driver. When adding support for another chip in the family, a new @@ -724,6 +725,7 @@ struct rtl8365mb_chip_info { const struct rtl8365mb_extint extints[RTL8365MB_MAX_NUM_EXTINTS]; const struct rtl8365mb_jam_tbl_entry *jam_table; size_t jam_size; + unsigned int num_tx_queues; }; /* Chip info for each supported switch in the family */ @@ -748,6 +750,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { }, .jam_table = rtl8365mb_init_jam_8365mb_vc, .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), + .num_tx_queues = 8, }, { .name = "RTL8367S", @@ -761,6 +764,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { }, .jam_table = rtl8365mb_init_jam_8365mb_vc, .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), + .num_tx_queues = 8, }, { .name = "RTL8367SB", @@ -776,6 +780,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { }, .jam_table = rtl8365mb_init_jam_8365mb_vc, .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), + .num_tx_queues = 8, }, { .name = "RTL8367RB-VB", @@ -790,6 +795,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { }, .jam_table = rtl8365mb_init_jam_8365mb_vc, .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), + .num_tx_queues = 8, }, }; @@ -3288,6 +3294,8 @@ static int rtl8365mb_setup(struct dsa_switch *ds) goto out_teardown_irq; } + ds->num_tx_queues = mb->chip_info->num_tx_queues; + /* Start statistics counter polling */ ret = rtl8365mb_stats_setup(priv); if (ret) { -- 2.47.3