On the Rx path, when a pull-dequeue operation is performed on a
software portal, available frame descriptors are put in a ring - a DMA
memory storage - for further usage. Create the needed rings for both
frame queues used on the control interface.
Signed-off-by: Ioana Ciornei <[email protected]>
---
drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 37 +++++++++++++++++++++++++++++++++
drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 6 ++++++
2 files changed, 43 insertions(+)
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 4ed335af2cc8..7b68eb22a951 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1459,6 +1459,33 @@ static void ethsw_free_dpbp(struct ethsw_core *ethsw)
fsl_mc_object_free(ethsw->dpbp_dev);
}
+static int ethsw_alloc_rings(struct ethsw_core *ethsw)
+{
+ int i;
+
+ for (i = 0; i < ETHSW_RX_NUM_FQS; i++) {
+ ethsw->fq[i].store =
+ dpaa2_io_store_create(DPAA2_ETHSW_STORE_SIZE,
+ ethsw->dev);
+ if (!ethsw->fq[i].store) {
+ dev_err(ethsw->dev, "dpaa2_io_store_create failed\n");
+ while (--i >= 0)
+ dpaa2_io_store_destroy(ethsw->fq[i].store);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+static void ethsw_destroy_rings(struct ethsw_core *ethsw)
+{
+ int i;
+
+ for (i = 0; i < ETHSW_RX_NUM_FQS; i++)
+ dpaa2_io_store_destroy(ethsw->fq[i].store);
+}
+
static int ethsw_ctrl_if_setup(struct ethsw_core *ethsw)
{
int err;
@@ -1473,7 +1500,16 @@ static int ethsw_ctrl_if_setup(struct ethsw_core *ethsw)
if (err)
return err;
+ err = ethsw_alloc_rings(ethsw);
+ if (err)
+ goto err_free_dpbp;
+
return 0;
+
+err_free_dpbp:
+ ethsw_free_dpbp(ethsw);
+
+ return err;
}
static int ethsw_init(struct fsl_mc_device *sw_dev)
@@ -1651,6 +1687,7 @@ static void ethsw_takedown(struct fsl_mc_device *sw_dev)
static void ethsw_ctrl_if_teardown(struct ethsw_core *ethsw)
{
+ ethsw_destroy_rings(ethsw);
ethsw_free_dpbp(ethsw);
}
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h
index c3cfd08c21c7..a1ca30c615d5 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h
@@ -19,6 +19,8 @@
#include <linux/if_bridge.h>
#include <linux/fsl/mc.h>
+#include <soc/fsl/dpaa2-io.h>
+
#include "dpsw.h"
/* Number of IRQs supported */
@@ -48,6 +50,9 @@
#define DPAA2_ETHSW_RX_BUF_SIZE \
(DPAA2_ETHSW_RX_BUF_RAW_SIZE - DPAA2_ETHSW_RX_BUF_TAILROOM)
+/* Dequeue store size */
+#define DPAA2_ETHSW_STORE_SIZE 16
+
extern const struct ethtool_ops ethsw_port_ethtool_ops;
struct ethsw_core;
@@ -55,6 +60,7 @@
struct ethsw_fq {
struct ethsw_core *ethsw;
enum dpsw_queue_type type;
+ struct dpaa2_io_store *store;
u32 fqid;
};
--
1.9.1