From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: [PATCH v2] virtio: fix size of mac_addrs array in virtio ports Date: Thu, 29 Oct 2015 10:16:50 +0100 Message-ID: <1446110210-25980-1-git-send-email-david.marchand@6wind.com> References: <1446108375-14178-1-git-send-email-david.marchand@6wind.com> To: dev@dpdk.org Return-path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id 8871B8EA1 for ; Thu, 29 Oct 2015 10:16:56 +0100 (CET) Received: by wicfx6 with SMTP id fx6so221481096wic.1 for ; Thu, 29 Oct 2015 02:16:56 -0700 (PDT) In-Reply-To: <1446108375-14178-1-git-send-email-david.marchand@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Boule Make the virtio PMD allocate the array of unicast MAC addresses with the maximum of entries (VIRTIO_MAX_MAC_ADDRS) that it exports. Signed-off-by: Ivan Boule Signed-off-by: David Marchand --- Changes since v1: * fix checkpatch warning (thanks Yuanhan) drivers/net/virtio/virtio_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 12fcc23..636b182 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1163,6 +1163,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) struct virtio_net_config *config; struct virtio_net_config local_config; struct rte_pci_device *pci_dev; + const size_t mac_array_size = VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN; RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr)); @@ -1175,11 +1176,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) } /* Allocate memory for storing MAC addresses */ - eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0); + eth_dev->data->mac_addrs = rte_zmalloc("virtio", mac_array_size, 0); if (eth_dev->data->mac_addrs == NULL) { PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to store MAC addresses", - ETHER_ADDR_LEN); + mac_array_size); return -ENOMEM; } -- 1.9.1