@@ -1580,6 +1580,33 @@ static void dpaa2_switch_free_dpbp(struct ethsw_core *ethsw)
fsl_mc_object_free(ethsw->dpbp_dev);
}
+static int dpaa2_switch_alloc_rings(struct ethsw_core *ethsw)
+{
+ int i;
+
+ for (i = 0; i < DPAA2_SWITCH_RX_NUM_FQS; i++) {
+ ethsw->fq[i].store =
+ dpaa2_io_store_create(DPAA2_SWITCH_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 dpaa2_switch_destroy_rings(struct ethsw_core *ethsw)
+{
+ int i;
+
+ for (i = 0; i < DPAA2_SWITCH_RX_NUM_FQS; i++)
+ dpaa2_io_store_destroy(ethsw->fq[i].store);
+}
+
static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw)
{
int err;
@@ -1594,7 +1621,16 @@ static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw)
if (err)
return err;
+ err = dpaa2_switch_alloc_rings(ethsw);
+ if (err)
+ goto err_free_dpbp;
+
return 0;
+
+err_free_dpbp:
+ dpaa2_switch_free_dpbp(ethsw);
+
+ return err;
}
static int dpaa2_switch_init(struct fsl_mc_device *sw_dev)
@@ -1777,6 +1813,7 @@ static void dpaa2_switch_takedown(struct fsl_mc_device *sw_dev)
static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw)
{
+ dpaa2_switch_destroy_rings(ethsw);
dpaa2_switch_free_dpbp(ethsw);
}
@@ -18,6 +18,7 @@
#include <net/switchdev.h>
#include <linux/if_bridge.h>
#include <linux/fsl/mc.h>
+#include <soc/fsl/dpaa2-io.h>
#include "dpsw.h"
@@ -50,6 +51,8 @@
#define DPAA2_SWITCH_RX_BUF_SIZE \
(DPAA2_SWITCH_RX_BUF_RAW_SIZE - DPAA2_SWITCH_RX_BUF_TAILROOM)
+#define DPAA2_SWITCH_STORE_SIZE 16
+
extern const struct ethtool_ops dpaa2_switch_port_ethtool_ops;
struct ethsw_core;
@@ -57,6 +60,7 @@ struct ethsw_core;
struct dpaa2_switch_fq {
struct ethsw_core *ethsw;
enum dpsw_queue_type type;
+ struct dpaa2_io_store *store;
u32 fqid;
};