On Mon, May 30, 2016 at 10:55:38AM +0000, Jianfeng Tan wrote:
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 41d8ad1..5e4f60b 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -166,3 +166,312 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
>       return vhost_call(dev->vhostfd, dev->type, VHOST_MSG_RESET_OWNER, NULL);
>  }
>  
> +static inline void parse_mac(struct virtio_user_dev *dev, const char *mac)

Note that this is a slight coding style offensive.

> +{
> +     int i, r;
> +     uint32_t tmp[ETHER_ADDR_LEN];
> +
> +     if (!mac)
> +             return;
> +
> +     r = sscanf(mac, "%x:%x:%x:%x:%x:%x", &tmp[0],
> +                     &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
> +     if (r == ETHER_ADDR_LEN) {
> +             for (i = 0; i < ETHER_ADDR_LEN; ++i)
> +                     dev->mac_addr[i] = (uint8_t)tmp[i];
> +             dev->mac_specified = 1;
> +     } else {
> +             /* ignore the wrong mac, use random mac */
> +             PMD_DRV_LOG(ERR, "wrong format of mac: %s", mac);
> +     }
> +}
> +
> +static int
> +virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
> +              int queue_size, const char *mac, char *ifname)

As stated in last email, we should move all others (except above 2
functions) to the driver layer, where they belong to.

        --yliu

Reply via email to