net/dpaa: add check for parsing default Rx queue
authorRohit Raj <rohit.raj@nxp.com>
Mon, 19 Jul 2021 13:59:14 +0000 (19:29 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 23 Jul 2021 17:44:05 +0000 (19:44 +0200)
Add check for the PCD queue from the kernel interface
for default and error queues.

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/bus/dpaa/base/fman/fman.c
drivers/bus/dpaa/include/fman.h
drivers/net/dpaa/dpaa_fmc.c

index a14004d..1814372 100644 (file)
@@ -214,7 +214,7 @@ fman_if_init(const struct device_node *dpa_node)
        const phandle *port_cell_idx, *ext_args_cell_idx;
        const struct device_node *parent_node_ext_args;
        uint64_t tx_phandle_host[4] = {0};
-       uint64_t rx_phandle_host[4] = {0};
+       uint64_t rx_phandle_host[6] = {0};
        uint64_t regs_addr_host = 0;
        uint64_t cell_idx_host = 0;
        uint64_t port_cell_idx_val = 0;
@@ -511,6 +511,10 @@ fman_if_init(const struct device_node *dpa_node)
                goto err;
        }
 
+       /* Check if "fsl,qman-frame-queues-rx" in dtb file is valid entry or
+        * not. A valid entry contains at least 4 entries, rx_error_queue,
+        * rx_error_queue_count, fqid_rx_def and rx_error_queue_count.
+        */
        assert(lenp >= (4 * sizeof(phandle)));
 
        na = of_n_addr_cells(mac_node);
@@ -519,11 +523,21 @@ fman_if_init(const struct device_node *dpa_node)
        rx_phandle_host[1] = of_read_number(&rx_phandle[1], na);
        rx_phandle_host[2] = of_read_number(&rx_phandle[2], na);
        rx_phandle_host[3] = of_read_number(&rx_phandle[3], na);
+       rx_phandle_host[4] = of_read_number(&rx_phandle[4], na);
+       rx_phandle_host[5] = of_read_number(&rx_phandle[5], na);
 
        assert((rx_phandle_host[1] == 1) && (rx_phandle_host[3] == 1));
        __if->__if.fqid_rx_err = rx_phandle_host[0];
        __if->__if.fqid_rx_def = rx_phandle_host[2];
 
+       /* If there are 6 entries in "fsl,qman-frame-queues-rx" in dtb file, it
+        * means PCD queues are also available. Hence, store that information.
+        */
+       if (lenp == 6 * sizeof(phandle)) {
+               __if->__if.fqid_rx_pcd = rx_phandle_host[4];
+               __if->__if.fqid_rx_pcd_count = rx_phandle_host[5];
+       }
+
        /* Extract the Tx FQIDs */
        tx_phandle = of_get_property(dpa_node,
                                     "fsl,qman-frame-queues-tx", &lenp);
index 516c6c1..3a6dd55 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Copyright 2010-2012 Freescale Semiconductor, Inc.
  * All rights reserved.
- * Copyright 2019-2020 NXP
+ * Copyright 2019-2021 NXP
  *
  */
 
@@ -329,8 +329,11 @@ struct fman_if {
        uint8_t is_shared_mac;
        /* The hard-coded FQIDs for this interface. Note: this doesn't cover
         * the PCD nor the "Rx default" FQIDs, which are configured via FMC
-        * and its XML-based configuration.
+        * and its XML-based configuration. These values are being parsed from
+        * kernel device tree.
         */
+       uint32_t fqid_rx_pcd;
+       uint32_t fqid_rx_pcd_count;
        uint32_t fqid_rx_def;
        uint32_t fqid_rx_err;
        uint32_t fqid_tx_err;
index 0ef3622..5195053 100644 (file)
@@ -243,7 +243,10 @@ static int dpaa_port_fmc_scheme_parse(struct fman_if *fif,
                        uint32_t fqid = fmc->scheme[idx].base_fqid + i;
                        int k, found = 0;
 
-                       if (fqid == fif->fqid_rx_def) {
+                       if (fqid == fif->fqid_rx_def ||
+                           (fqid >= fif->fqid_rx_pcd &&
+                                       fqid < (fif->fqid_rx_pcd +
+                                               fif->fqid_rx_pcd_count))) {
                                if (fif->is_shared_mac &&
                                fmc->scheme[idx].override_storage_profile &&
                                fmc->scheme[idx].storage_profile.direct &&