[PATCH v2 5/6] net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support

Paolo Abeni pabeni at redhat.com
Thu Feb 1 23:01:51 AEDT 2024


On Tue, 2024-01-30 at 09:40 +0100, Herve Codina wrote:
> QMC channels support runtime timeslots changes but nothing is done at
> the QMC HDLC driver to handle these changes.
> 
> Use existing IFACE ioctl in order to configure the timeslots to use.
> 
> Signed-off-by: Herve Codina <herve.codina at bootlin.com>
> Reviewed-by: Christophe Leroy <christophe.leroy at csgroup.eu>
> Acked-by: Jakub Kicinski <kuba at kernel.org>
> ---
>  drivers/net/wan/fsl_qmc_hdlc.c | 155 ++++++++++++++++++++++++++++++++-
>  1 file changed, 154 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wan/fsl_qmc_hdlc.c b/drivers/net/wan/fsl_qmc_hdlc.c
> index e7b2b72a6050..8316f2984864 100644
> --- a/drivers/net/wan/fsl_qmc_hdlc.c
> +++ b/drivers/net/wan/fsl_qmc_hdlc.c
> @@ -7,6 +7,7 @@
>   * Author: Herve Codina <herve.codina at bootlin.com>
>   */
>  
> +#include <linux/bitmap.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/hdlc.h>
>  #include <linux/module.h>
> @@ -32,6 +33,7 @@ struct qmc_hdlc {
>  	struct qmc_hdlc_desc tx_descs[8];
>  	unsigned int tx_out;
>  	struct qmc_hdlc_desc rx_descs[4];
> +	u32 slot_map;
>  };
>  
>  static inline struct qmc_hdlc *netdev_to_qmc_hdlc(struct net_device *netdev)
> @@ -202,6 +204,147 @@ static netdev_tx_t qmc_hdlc_xmit(struct sk_buff *skb, struct net_device *netdev)
>  	return NETDEV_TX_OK;
>  }
>  
> +static int qmc_hdlc_xlate_slot_map(struct qmc_hdlc *qmc_hdlc,
> +				   u32 slot_map, struct qmc_chan_ts_info *ts_info)
> +{
> +	DECLARE_BITMAP(ts_mask_avail, 64);
> +	DECLARE_BITMAP(ts_mask, 64);
> +	DECLARE_BITMAP(map, 64);
> +	u32 array32[2];
> +
> +	/* Tx and Rx available masks must be identical */
> +	if (ts_info->rx_ts_mask_avail != ts_info->tx_ts_mask_avail) {
> +		dev_err(qmc_hdlc->dev, "tx and rx available timeslots mismatch (0x%llx, 0x%llx)\n",
> +			ts_info->rx_ts_mask_avail, ts_info->tx_ts_mask_avail);
> +		return -EINVAL;
> +	}
> +
> +	bitmap_from_arr64(ts_mask_avail, &ts_info->rx_ts_mask_avail, 64);
> +	array32[0] = slot_map;
> +	array32[1] = 0;
> +	bitmap_from_arr32(map, array32, 64);

What about using bitmap_from_u64 everywhere ?

Cheers,

Paolo



More information about the Linuxppc-dev mailing list