Skip to content

Commit

Permalink
net: renesas: rswitch: Move linkfix variables to rswitch_gwca
Browse files Browse the repository at this point in the history
To improve readability, move linkfix related variables to
struct rswitch_gwca. Also, rename function names "desc" with "linkfix".

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Yoshihiro Shimoda authored and Jakub Kicinski committed Feb 11, 2023
1 parent 251eadc commit e3f3803
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
39 changes: 21 additions & 18 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static int rswitch_gwca_queue_format(struct net_device *ndev,
rswitch_desc_set_dptr(&desc->desc, gq->ring_dma);
desc->desc.die_dt = DT_LINKFIX;

linkfix = &priv->linkfix_table[gq->index];
linkfix = &priv->gwca.linkfix_table[gq->index];
linkfix->die_dt = DT_LINKFIX;
rswitch_desc_set_dptr(linkfix, gq->ring_dma);

Expand Down Expand Up @@ -470,7 +470,7 @@ static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev,
rswitch_desc_set_dptr(&desc->desc, gq->ring_dma);
desc->desc.die_dt = DT_LINKFIX;

linkfix = &priv->linkfix_table[gq->index];
linkfix = &priv->gwca.linkfix_table[gq->index];
linkfix->die_dt = DT_LINKFIX;
rswitch_desc_set_dptr(linkfix, gq->ring_dma);

Expand All @@ -480,28 +480,31 @@ static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev,
return 0;
}

static int rswitch_gwca_desc_alloc(struct rswitch_private *priv)
static int rswitch_gwca_linkfix_alloc(struct rswitch_private *priv)
{
int i, num_queues = priv->gwca.num_queues;
struct rswitch_gwca *gwca = &priv->gwca;
struct device *dev = &priv->pdev->dev;

priv->linkfix_table_size = sizeof(struct rswitch_desc) * num_queues;
priv->linkfix_table = dma_alloc_coherent(dev, priv->linkfix_table_size,
&priv->linkfix_table_dma, GFP_KERNEL);
if (!priv->linkfix_table)
gwca->linkfix_table_size = sizeof(struct rswitch_desc) * num_queues;
gwca->linkfix_table = dma_alloc_coherent(dev, gwca->linkfix_table_size,
&gwca->linkfix_table_dma, GFP_KERNEL);
if (!gwca->linkfix_table)
return -ENOMEM;
for (i = 0; i < num_queues; i++)
priv->linkfix_table[i].die_dt = DT_EOS;
gwca->linkfix_table[i].die_dt = DT_EOS;

return 0;
}

static void rswitch_gwca_desc_free(struct rswitch_private *priv)
static void rswitch_gwca_linkfix_free(struct rswitch_private *priv)
{
if (priv->linkfix_table)
dma_free_coherent(&priv->pdev->dev, priv->linkfix_table_size,
priv->linkfix_table, priv->linkfix_table_dma);
priv->linkfix_table = NULL;
struct rswitch_gwca *gwca = &priv->gwca;

if (gwca->linkfix_table)
dma_free_coherent(&priv->pdev->dev, gwca->linkfix_table_size,
gwca->linkfix_table, gwca->linkfix_table_dma);
gwca->linkfix_table = NULL;
}

static struct rswitch_gwca_queue *rswitch_gwca_get(struct rswitch_private *priv)
Expand Down Expand Up @@ -617,8 +620,8 @@ static int rswitch_gwca_hw_init(struct rswitch_private *priv)

iowrite32(GWVCC_VEM_SC_TAG, priv->addr + GWVCC);
iowrite32(0, priv->addr + GWTTFC);
iowrite32(lower_32_bits(priv->linkfix_table_dma), priv->addr + GWDCBAC1);
iowrite32(upper_32_bits(priv->linkfix_table_dma), priv->addr + GWDCBAC0);
iowrite32(lower_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCBAC1);
iowrite32(upper_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCBAC0);
rswitch_gwca_set_rate_limit(priv, priv->gwca.speed);

for (i = 0; i < RSWITCH_NUM_PORTS; i++) {
Expand Down Expand Up @@ -1650,7 +1653,7 @@ static int rswitch_init(struct rswitch_private *priv)
if (err < 0)
return err;

err = rswitch_gwca_desc_alloc(priv);
err = rswitch_gwca_linkfix_alloc(priv);
if (err < 0)
return -ENOMEM;

Expand Down Expand Up @@ -1712,7 +1715,7 @@ static int rswitch_init(struct rswitch_private *priv)
rswitch_device_free(priv, i);

err_device_alloc:
rswitch_gwca_desc_free(priv);
rswitch_gwca_linkfix_free(priv);

return err;
}
Expand Down Expand Up @@ -1791,7 +1794,7 @@ static void rswitch_deinit(struct rswitch_private *priv)
rswitch_device_free(priv, i);
}

rswitch_gwca_desc_free(priv);
rswitch_gwca_linkfix_free(priv);

rswitch_clock_disable(priv);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/renesas/rswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,9 @@ struct rswitch_gwca_queue {
#define RSWITCH_NUM_IRQ_REGS (RSWITCH_MAX_NUM_QUEUES / BITS_PER_TYPE(u32))
struct rswitch_gwca {
int index;
struct rswitch_desc *linkfix_table;
dma_addr_t linkfix_table_dma;
u32 linkfix_table_size;
struct rswitch_gwca_queue *queues;
int num_queues;
DECLARE_BITMAP(used, RSWITCH_MAX_NUM_QUEUES);
Expand Down Expand Up @@ -969,9 +972,6 @@ struct rswitch_private {
struct platform_device *pdev;
void __iomem *addr;
struct rcar_gen4_ptp_private *ptp_priv;
struct rswitch_desc *linkfix_table;
dma_addr_t linkfix_table_dma;
u32 linkfix_table_size;

struct rswitch_device *rdev[RSWITCH_NUM_PORTS];

Expand Down

0 comments on commit e3f3803

Please sign in to comment.