Hi Breno > -----Original Message----- > From: Breno Leitao <leitao@xxxxxxxxxx> > Sent: Wednesday, July 3, 2024 12:26 AM > To: kuba@xxxxxxxxxx; Horia Geanta <horia.geanta@xxxxxxx>; Pankaj Gupta > <pankaj.gupta@xxxxxxx>; Gaurav Jain <gaurav.jain@xxxxxxx>; linux- > crypto@xxxxxxxxxxxxxxx; Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>; David S. > Miller <davem@xxxxxxxxxxxxx> > Cc: horms@xxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx > Subject: [EXT] [PATCH net-next v3 4/4] crypto: caam: Unembed net_dev > structure in dpaa2 > > Caution: This is an external email. Please take care when clicking links or opening > attachments. When in doubt, report the message using the 'Report this email' > button > > > Embedding net_device into structures prohibits the usage of flexible arrays in the > net_device structure. For more details, see the discussion at [1]. > > Un-embed the net_devices from struct dpaa2_caam_priv_per_cpu by converting > them into pointers, and allocating them dynamically. Use the leverage > alloc_netdev_dummy() to allocate the net_device object at > dpaa2_dpseci_setup(). > > The free of the device occurs at dpaa2_dpseci_disable(). > > Link: > https://lore.kernel/ > .org%2Fall%2F20240229225910.79e224cf%40kernel.org%2F&data=05%7C02%7 > Cgaurav.jain%40nxp.com%7C5748b86d20dc4be03e0b08dc9ac8bfae%7C686ea1d > 3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638555434196331223%7CUnknow > n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw > iLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=LtDEO2Ko6WFFfip9iyj%2BQycgsBE > LG3barb9byRSxQCg%3D&reserved=0 [1] > Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx> > --- > drivers/crypto/caam/caamalg_qi2.c | 28 +++++++++++++++++++++++++--- > drivers/crypto/caam/caamalg_qi2.h | 2 +- > 2 files changed, 26 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/caam/caamalg_qi2.c > b/drivers/crypto/caam/caamalg_qi2.c > index a4f6884416a0..207dc422785a 100644 > --- a/drivers/crypto/caam/caamalg_qi2.c > +++ b/drivers/crypto/caam/caamalg_qi2.c > @@ -4990,11 +4990,23 @@ static int dpaa2_dpseci_congestion_setup(struct > dpaa2_caam_priv *priv, > return err; > } > > +static void free_dpaa2_pcpu_netdev(struct dpaa2_caam_priv *priv, const > +cpumask_t *cpus) { > + struct dpaa2_caam_priv_per_cpu *ppriv; > + int i; > + > + for_each_cpu(i, cpus) { > + ppriv = per_cpu_ptr(priv->ppriv, i); > + free_netdev(ppriv->net_dev); > + } > +} > + > static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev) { > struct device *dev = &ls_dev->dev; > struct dpaa2_caam_priv *priv; > struct dpaa2_caam_priv_per_cpu *ppriv; > + cpumask_t clean_mask; > int err, cpu; > u8 i; > > @@ -5073,6 +5085,7 @@ static int __cold dpaa2_dpseci_setup(struct > fsl_mc_device *ls_dev) > } > } > > + cpumask_clear(&clean_mask); > i = 0; > for_each_online_cpu(cpu) { > u8 j; > @@ -5096,15 +5109,23 @@ static int __cold dpaa2_dpseci_setup(struct > fsl_mc_device *ls_dev) > priv->rx_queue_attr[j].fqid, > priv->tx_queue_attr[j].fqid); > > - ppriv->net_dev.dev = *dev; > - INIT_LIST_HEAD(&ppriv->net_dev.napi_list); napi_list is not needed anymore? There is no mention in commit. Regards Gaurav Jain > - netif_napi_add_tx_weight(&ppriv->net_dev, &ppriv->napi, > + ppriv->net_dev = alloc_netdev_dummy(0); > + if (!ppriv->net_dev) { > + err = -ENOMEM; > + goto err_alloc_netdev; > + } > + cpumask_set_cpu(cpu, &clean_mask); > + ppriv->net_dev->dev = *dev; > + > + netif_napi_add_tx_weight(ppriv->net_dev, &ppriv->napi, > dpaa2_dpseci_poll, > DPAA2_CAAM_NAPI_WEIGHT); > } > > return 0; > > +err_alloc_netdev: > + free_dpaa2_pcpu_netdev(priv, &clean_mask); > err_get_rx_queue: > dpaa2_dpseci_congestion_free(priv); > err_get_vers: > @@ -5153,6 +5174,7 @@ static int __cold dpaa2_dpseci_disable(struct > dpaa2_caam_priv *priv) > ppriv = per_cpu_ptr(priv->ppriv, i); > napi_disable(&ppriv->napi); > netif_napi_del(&ppriv->napi); > + free_netdev(ppriv->net_dev); > } > > return 0; > diff --git a/drivers/crypto/caam/caamalg_qi2.h > b/drivers/crypto/caam/caamalg_qi2.h > index abb502bb675c..61d1219a202f 100644 > --- a/drivers/crypto/caam/caamalg_qi2.h > +++ b/drivers/crypto/caam/caamalg_qi2.h > @@ -81,7 +81,7 @@ struct dpaa2_caam_priv { > */ > struct dpaa2_caam_priv_per_cpu { > struct napi_struct napi; > - struct net_device net_dev; > + struct net_device *net_dev; > int req_fqid; > int rsp_fqid; > int prio; > -- > 2.43.0