RE: [PATCH linux-next 4/9] vdpa_sim_net: Enable user to set mac address and mtu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> From: Michael S. Tsirkin <mst@xxxxxxxxxx>
> Sent: Wednesday, February 24, 2021 12:27 PM
> 
> On Wed, Feb 24, 2021 at 08:18:39AM +0200, Parav Pandit wrote:
> > Enable user to set the mac address and mtu so that each vdpa device
> > can have its own user specified mac address and mtu.
> > This is done by implementing the management device's configuration
> > layout fields setting callback routine.
> >
> > Now that user is enabled to set the mac address, remove the module
> > parameter for same.
> 
> Will likely break some testing setups ...
> Not too hard to keep it around, is it?
>
Mostly not. In previous series, we moved away from default device to user created device without an additional module param.
So this shouldn't break it.
It gets confusing which one to use and module param applies same mac to all the vdpa devices.
So lets shift to user provided mac.

> >
> > And example of setting mac addr and mtu:
> > $ vdpa mgmtdev show
> >
> > $ vdpa dev add name bar mgmtdev vdpasim_net $ vdpa dev config set bar
> > mac 00:11:22:33:44:55 mtu 9000
> >
> > View the config after setting:
> > $ vdpa dev config show
> > bar: mac 00:11:22:33:44:55 link up link_announce false mtu 9000 speed
> > 0 duplex 0
> >
> > Signed-off-by: Parav Pandit <parav@xxxxxxxxxx>
> > Reviewed-by: Eli Cohen <elic@xxxxxxxxxx>
> > ---
> >  drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 39
> > ++++++++++++++++------------
> >  1 file changed, 22 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> > b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> > index 240a5f1306b5..6e941b0e7935 100644
> > --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
> > @@ -29,12 +29,6 @@
> >
> >  #define VDPASIM_NET_VQ_NUM	2
> >
> > -static char *macaddr;
> > -module_param(macaddr, charp, 0);
> > -MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
> > -
> > -static u8 macaddr_buf[ETH_ALEN];
> > -
> >  static void vdpasim_net_work(struct work_struct *work)  {
> >  	struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
> > @@ -113,9 +107,7 @@ static void vdpasim_net_get_config(struct vdpasim
> *vdpasim, void *config)
> >  	struct virtio_net_config *net_config =
> >  		(struct virtio_net_config *)config;
> >
> > -	net_config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
> >  	net_config->status = cpu_to_vdpasim16(vdpasim,
> VIRTIO_NET_S_LINK_UP);
> > -	memcpy(net_config->mac, macaddr_buf, ETH_ALEN);
> >  }
> >
> >  static void vdpasim_net_mgmtdev_release(struct device *dev) @@ -134,6
> > +126,7 @@ static struct device vdpasim_net_mgmtdev_dummy = {
> >
> >  static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char
> > *name)  {
> > +	struct virtio_net_config *cfg;
> >  	struct vdpasim_dev_attr dev_attr = {};
> >  	struct vdpasim *simdev;
> >  	int ret;
> > @@ -152,6 +145,10 @@ static int vdpasim_net_dev_add(struct
> vdpa_mgmt_dev *mdev, const char *name)
> >  	if (IS_ERR(simdev))
> >  		return PTR_ERR(simdev);
> >
> > +	cfg = simdev->config;
> > +	eth_random_addr(cfg->mac);
> > +	cfg->mtu = cpu_to_vdpasim16(simdev, 1500);
> > +
> >  	ret = _vdpa_register_device(&simdev->vdpa);
> >  	if (ret)
> >  		goto reg_err;
> 
> Hmm moving it here is problematic:
> this part happens before set_features so I suspect endian-ness will be wrong
> for BE hosts ...
>
Hmm. I see it. Looking for solution to it now.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux