mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
staging: fsl-dpaa2/eth: Split function
Since setup_dpni() became a bit too long, move the buffer layout configuration to a separate function. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f6dda80902
commit
308f64e7e2
1 changed files with 46 additions and 35 deletions
|
@ -1776,13 +1776,56 @@ static void free_dpbp(struct dpaa2_eth_priv *priv)
|
|||
fsl_mc_object_free(priv->dpbp_dev);
|
||||
}
|
||||
|
||||
static int set_buffer_layout(struct dpaa2_eth_priv *priv)
|
||||
{
|
||||
struct device *dev = priv->net_dev->dev.parent;
|
||||
struct dpni_buffer_layout buf_layout = {0};
|
||||
int err;
|
||||
|
||||
/* rx buffer */
|
||||
buf_layout.pass_parser_result = true;
|
||||
buf_layout.pass_frame_status = true;
|
||||
buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
|
||||
buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
|
||||
DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
|
||||
DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
|
||||
DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_RX, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* tx buffer */
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
|
||||
DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_TX, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* tx-confirm buffer */
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_TX_CONFIRM, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Configure the DPNI object this interface is associated with */
|
||||
static int setup_dpni(struct fsl_mc_device *ls_dev)
|
||||
{
|
||||
struct device *dev = &ls_dev->dev;
|
||||
struct dpaa2_eth_priv *priv;
|
||||
struct net_device *net_dev;
|
||||
struct dpni_buffer_layout buf_layout = {0};
|
||||
int err;
|
||||
|
||||
net_dev = dev_get_drvdata(dev);
|
||||
|
@ -1811,41 +1854,9 @@ static int setup_dpni(struct fsl_mc_device *ls_dev)
|
|||
goto close;
|
||||
}
|
||||
|
||||
/* Configure buffer layouts */
|
||||
/* rx buffer */
|
||||
buf_layout.pass_parser_result = true;
|
||||
buf_layout.pass_frame_status = true;
|
||||
buf_layout.private_data_size = DPAA2_ETH_SWA_SIZE;
|
||||
buf_layout.data_align = DPAA2_ETH_RX_BUF_ALIGN;
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
|
||||
DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
|
||||
DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE |
|
||||
DPNI_BUF_LAYOUT_OPT_DATA_ALIGN;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_RX, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(RX) failed\n");
|
||||
err = set_buffer_layout(priv);
|
||||
if (err)
|
||||
goto close;
|
||||
}
|
||||
|
||||
/* tx buffer */
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
|
||||
DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_TX, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(TX) failed\n");
|
||||
goto close;
|
||||
}
|
||||
|
||||
/* tx-confirm buffer */
|
||||
buf_layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
|
||||
err = dpni_set_buffer_layout(priv->mc_io, 0, priv->mc_token,
|
||||
DPNI_QUEUE_TX_CONFIRM, &buf_layout);
|
||||
if (err) {
|
||||
dev_err(dev, "dpni_set_buffer_layout(TX_CONF) failed\n");
|
||||
goto close;
|
||||
}
|
||||
|
||||
/* Now that we've set our tx buffer layout, retrieve the minimum
|
||||
* required tx data offset.
|
||||
|
|
Loading…
Reference in a new issue