mlx4: move to drivers/net/
[dpdk.git] / lib / librte_pmd_null / rte_eth_null.c
index f49d686..5895065 100644 (file)
@@ -160,11 +160,12 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
        int i;
        struct null_queue *h = q;
-       unsigned packet_size = h->internals->packet_size;
+       unsigned packet_size;
 
        if ((q == NULL) || (bufs == NULL))
                return 0;
 
+       packet_size = h->internals->packet_size;
        for (i = 0; i < nb_bufs; i++) {
                rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(bufs[i], void *),
                                        packet_size);
@@ -354,26 +355,25 @@ eth_queue_release(void *q)
                return;
 
        nq = q;
-       if (nq->dummy_packet)
-               rte_free(nq->dummy_packet);
+       rte_free(nq->dummy_packet);
 }
 
 static int
 eth_link_update(struct rte_eth_dev *dev __rte_unused,
                int wait_to_complete __rte_unused) { return 0; }
 
-static struct eth_dev_ops ops = {
-               .dev_start = eth_dev_start,
-               .dev_stop = eth_dev_stop,
-               .dev_configure = eth_dev_configure,
-               .dev_infos_get = eth_dev_info,
-               .rx_queue_setup = eth_rx_queue_setup,
-               .tx_queue_setup = eth_tx_queue_setup,
-               .rx_queue_release = eth_queue_release,
-               .tx_queue_release = eth_queue_release,
-               .link_update = eth_link_update,
-               .stats_get = eth_stats_get,
-               .stats_reset = eth_stats_reset,
+static const struct eth_dev_ops ops = {
+       .dev_start = eth_dev_start,
+       .dev_stop = eth_dev_stop,
+       .dev_configure = eth_dev_configure,
+       .dev_infos_get = eth_dev_info,
+       .rx_queue_setup = eth_rx_queue_setup,
+       .tx_queue_setup = eth_tx_queue_setup,
+       .rx_queue_release = eth_queue_release,
+       .tx_queue_release = eth_queue_release,
+       .link_update = eth_link_update,
+       .stats_get = eth_stats_get,
+       .stats_reset = eth_stats_reset,
 };
 
 static int
@@ -457,12 +457,10 @@ eth_dev_null_create(const char *name,
        return 0;
 
 error:
-       if (data)
-               rte_free(data);
-       if (pci_dev)
-               rte_free(pci_dev);
-       if (internals)
-               rte_free(internals);
+       rte_free(data);
+       rte_free(pci_dev);
+       rte_free(internals);
+
        return -1;
 }
 
@@ -506,7 +504,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
        unsigned numa_node;
        unsigned packet_size = default_packet_size;
        unsigned packet_copy = default_packet_copy;
-       struct rte_kvargs *kvlist;
+       struct rte_kvargs *kvlist = NULL;
        int ret;
 
        if (name == NULL)
@@ -527,7 +525,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
                                        ETH_NULL_PACKET_SIZE_ARG,
                                        &get_packet_size_arg, &packet_size);
                        if (ret < 0)
-                               return -1;
+                               goto free_kvlist;
                }
 
                if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) {
@@ -536,7 +534,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
                                        ETH_NULL_PACKET_COPY_ARG,
                                        &get_packet_copy_arg, &packet_copy);
                        if (ret < 0)
-                               return -1;
+                               goto free_kvlist;
                }
        }
 
@@ -544,7 +542,12 @@ rte_pmd_null_devinit(const char *name, const char *params)
                        "packet copy is %s\n", packet_size,
                        packet_copy ? "enabled" : "disabled");
 
-       return eth_dev_null_create(name, numa_node, packet_size, packet_copy);
+       ret = eth_dev_null_create(name, numa_node, packet_size, packet_copy);
+
+free_kvlist:
+       if (kvlist)
+               rte_kvargs_free(kvlist);
+       return ret;
 }
 
 static int