Skip to contentSkip to conversation

net/enic: fix another case of memory not being freed

PATCH Applied John Daley 2 participants 4 messages Sep 22, 2016 – Sep 27, 2016 Network drivers

lore
Share & tools
lore

John Daley

author
#0 lore raw

PATCH 1/1 net/enic: fix another case of memory not being freed

From: Nelson Escobar <[email protected]>

The function vnic_dev_free_desc_ring() didn't actually free memory. Fix this by first changing vnic_dev_alloc_desc_ring() to use the common allocation function, then in vnic_dev_free_desc_ring call the common free function.

Fixes fefed3d1e62c ("enic: new driver")
---
 drivers/net/enic/base/vnic_dev.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/enic/base/vnic_dev.c +22 -14
index fc2e4cc..4db21a4 100644
@@ -266,32 +266,35 @@ void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring)
 	memset(ring->descs, 0, ring->size);
 }
 
-int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev,
+int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev,
 	struct vnic_dev_ring *ring,
-	unsigned int desc_count, unsigned int desc_size, unsigned int socket_id,
+	unsigned int desc_count, unsigned int desc_size,
+	__attribute__((unused)) unsigned int socket_id,
 	char *z_name)
 {
-	const struct rte_memzone *rz;
+	void *alloc_addr = NULL;
+	dma_addr_t alloc_pa = 0;
 
 	vnic_dev_desc_ring_size(ring, desc_count, desc_size);
-
-	rz = rte_memzone_reserve_aligned(z_name,
-		ring->size_unaligned, socket_id,
-		0, ENIC_ALIGN);
-	if (!rz) {
+	alloc_addr = vdev->alloc_consistent(vdev->priv,
+					    ring->size_unaligned,
+					    &alloc_pa, (u8 *)z_name);
+	if (!alloc_addr) {
 		pr_err("Failed to allocate ring (size=%d), aborting\n",
 			(int)ring->size);
 		return -ENOMEM;
 	}
-
-	ring->descs_unaligned = rz->addr;
-	if (!ring->descs_unaligned) {
+	ring->descs_unaligned = alloc_addr;
+	if (!alloc_pa) {
 		pr_err("Failed to map allocated ring (size=%d), aborting\n",
 			(int)ring->size);
+		vdev->free_consistent(vdev->priv,
+				      ring->size_unaligned,
+				      alloc_addr,
+				      alloc_pa);
 		return -ENOMEM;
 	}
-
-	ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr;
+	ring->base_addr_unaligned = alloc_pa;
 
 	ring->base_addr = VNIC_ALIGN(ring->base_addr_unaligned,
 		ring->base_align);
@@ -308,8 +311,13 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct vnic_dev *vdev,
 void vnic_dev_free_desc_ring(__attribute__((unused))  struct vnic_dev *vdev,
 	struct vnic_dev_ring *ring)
 {
-	if (ring->descs)
+	if (ring->descs) {
+		vdev->free_consistent(vdev->priv,
+				      ring->size_unaligned,
+				      ring->descs_unaligned,
+				      ring->base_addr_unaligned);
 		ring->descs = NULL;
+	}
 }
 
 static int _vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
Signature · 1 line
2.10.0
author
#1 lore raw

PATCH 1/1 net/enic: support scatter Rx in the MTU update function

Re-initialize Rq's when MTU is changed. This allows for more efficient use of mbufs when moving from an MTU that is greater than the mbuf size to one that is less. And moves to using Rx scatter mode when moving from an MTU less than the mbuf size to one that is greater.

---
 drivers/net/enic/base/vnic_rq.h |   1 +
 drivers/net/enic/enic.h         |   9 +++
 drivers/net/enic/enic_main.c    | 145 +++++++++++++++++++++++++++++++++++++---
 drivers/net/enic/enic_rxtx.c    |  11 +++
 4 files changed, 156 insertions(+), 10 deletions(-)
drivers/net/enic/base/vnic_rq.h +1 -0
index fd9e170..7d96b0f 100644
@@ -96,6 +96,7 @@ struct vnic_rq {
 	struct rte_mbuf *pkt_first_seg;
 	struct rte_mbuf *pkt_last_seg;
 	unsigned int max_mbufs_per_pkt;
+	uint16_t tot_nb_desc;
 };
 
 static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
drivers/net/enic/enic.h +9 -0
index 5c9345f..17d6c05 100644
@@ -160,9 +160,15 @@ struct enic {
 	/* linked list storing memory allocations */
 	LIST_HEAD(enic_memzone_list, enic_memzone_entry) memzone_list;
 	rte_spinlock_t memzone_list_lock;
+	rte_spinlock_t mtu_lock;
 
 };
 
+static inline unsigned int enic_rq_sop(unsigned int sop_rq)
+{
+	return sop_rq / 2;
+}
+
 static inline unsigned int enic_sop_rq(unsigned int rq)
 {
 	return rq * 2;
@@ -270,6 +276,9 @@ extern int enic_clsf_init(struct enic *enic);
 extern void enic_clsf_destroy(struct enic *enic);
 uint16_t enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			uint16_t nb_pkts);
+uint16_t enic_dummy_recv_pkts(__rte_unused void *rx_queue,
+			      __rte_unused struct rte_mbuf **rx_pkts,
+			      __rte_unused uint16_t nb_pkts);
 uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
 int enic_set_mtu(struct enic *enic, uint16_t new_mtu);
drivers/net/enic/enic_main.c +135 -10

212 lines not on this page · raw message

drivers/net/enic/enic_rxtx.c +11 -0
index c138160..a80ccb6 100644
@@ -227,6 +227,17 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
 	mbuf->ol_flags = pkt_flags;
 }
 
+/* dummy receive function to replace actual function in
+ * order to do safe reconfiguration operations.
+ */
+uint16_t
+enic_dummy_recv_pkts(__rte_unused void *rx_queue,
+		     __rte_unused struct rte_mbuf **rx_pkts,
+		     __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
 uint16_t
 enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	       uint16_t nb_pkts)
Signature · 1 line
2.10.0
#2 lore raw

Re: [PATCH] net/enic: support scatter Rx in the MTU update function

Quoted 8 lines · John Daley

Re-initialize Rq's when MTU is changed. This allows for more efficient use of mbufs when moving from an MTU that is greater than the mbuf size to one that is less. And moves to using Rx scatter mode when moving from an MTU less than the mbuf size to one that is greater.

Applied to dpdk-next-net/rel_16_11

/Bruce

#3 lore raw
In reply to John Daley
Quoted 10 lines · John Daley

From: Nelson Escobar <[email protected]>

The function vnic_dev_free_desc_ring() didn't actually free memory. Fix this by first changing vnic_dev_alloc_desc_ring() to use the common allocation function, then in vnic_dev_free_desc_ring call the common free function.

Fixes fefed3d1e62c ("enic: new driver")

Applied to dpdk-next-net/rel_16_11

/Bruce