DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/6] link bonding
@ 2014-08-19 13:51 Declan Doherty
  2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
                   ` (14 more replies)
  0 siblings, 15 replies; 93+ messages in thread
From: Declan Doherty @ 2014-08-19 13:51 UTC (permalink / raw)
  To: dev

This patch set adds support for link status interrupt in the link bonding
pmd. It also contains some patches to tidy up the code structure and to
of the link bonding code and to fix bugs relating to transmission 
failures in the under lying slave pmd which could lead to leaked mbufs.  


Declan Doherty (6):
  bond: link status interrupt support
  bond: removing switch statement from rx burst method
  bond: fix naming inconsistency in tx_burst_round_robin
  bond: free mbufs if transmission fails in bonding tx_burst functions
  test app: adding support for generating variable sized packets
  testpmd: adding parameter to reconfig method to set socket_id when
    adding new port to portlist

 app/test-pmd/cmdline.c                 |    2 +-
 app/test-pmd/testpmd.c                 |    3 +-
 app/test-pmd/testpmd.h                 |    2 +-
 app/test/packet_burst_generator.c      |   22 +--
 app/test/packet_burst_generator.h      |    6 +-
 app/test/test_link_bonding.c           |  234 ++++++++++++++++++++++++++------
 lib/librte_pmd_bond/rte_eth_bond_api.c |    4 +
 lib/librte_pmd_bond/rte_eth_bond_pmd.c |  124 +++++++++++------
 8 files changed, 295 insertions(+), 102 deletions(-)

^ permalink raw reply	[flat|nested] 93+ messages in thread
* Re: [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions
@ 2014-08-20 20:54 Sanford, Robert
  2014-08-29 15:36 ` Thomas Monjalon
  0 siblings, 1 reply; 93+ messages in thread
From: Sanford, Robert @ 2014-08-20 20:54 UTC (permalink / raw)
  To: Declan Doherty, dev

Hi Declan,

I have a problem with the TX-burst logic of this patch. I believe that for
packets that we *don't* enqueue to the device, we should *NOT* free them.
The API expects that the caller will free them or try again to send them.

Here is one way to accomplish selective freeing: Move mbuf pointers of
packets successfully enqueued, to the beginning of the caller's mbuf
vector; move mbuf pointers of packets not enqueued, to the end of the
caller's mbuf list. Although possibly re-ordered, the caller will be able
to free/resend all (and only) mbufs that we failed to enqueue.

Here is a code snippet to do this:

  uint16_t failed_index = nb_pkts;

  /* Send packet burst on each slave device */
  for (i = 0; i < num_of_slaves; i++) {
    if (slave_nb_pkts[i] > 0) {
      num_tx_slave = rte_eth_tx_burst(slaves[i],
          bd_tx_q->queue_id, slave_bufs[i], slave_nb_pkts[i]);

    
      /* Move sent packets to the beginning of the caller's array. */
      if (likely(num_tx_slave)) {
        memcpy(&bufs[num_tx_total], slave_bufs[i],
            num_tx_slave * sizeof(void *));
        num_tx_total += num_tx_slave;
      }

    
      /* Move failed packets to the end of the caller's array,
       * so that the caller can free or resend the correct ones.
       */
      if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
        uint16_t num_failed = slave_nb_pkts[i] - num_tx_slave;
        failed_index -= num_failed;
        memcpy(&bufs[failed_index], &slave_bufs[i][num_tx_slave],
            num_failed * sizeof(void *));
      }
    }
  }       
 


--
Regards,
Robert


>Fixing a number of corner cases that if transmission failed on slave
>devices then this
>could lead to leaked mbufs
>
>
>Signed-off-by: Declan Doherty <declan.doherty@intel.com>
>---
> app/test/test_link_bonding.c           |    4 +-
> lib/librte_pmd_bond/rte_eth_bond_pmd.c |   46
>+++++++++++++++++++++++++-------
> 2 files changed, 38 insertions(+), 12 deletions(-)
>
>diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
>index 02823b6..3c265ee 100644
>--- a/app/test/test_link_bonding.c
>+++ b/app/test/test_link_bonding.c
>@@ -3415,7 +3415,7 @@ test_broadcast_tx_burst(void)
> 	/* Send burst on bonded port */
> 	nb_tx = rte_eth_tx_burst(test_params->bonded_port_id, 0, pkts_burst,
> 			burst_size);
>-	if (nb_tx != burst_size * test_params->bonded_slave_count) {
>+	if (nb_tx != burst_size) {
> 		printf("Bonded Port (%d) rx burst failed, packets transmitted value
>(%u) not as expected (%d)\n",
> 				test_params->bonded_port_id,
> 				nb_tx, burst_size);
>@@ -3770,7 +3770,7 @@
>test_broadcast_verify_slave_link_status_change_behaviour(void)
> 	}
> 
> 	if (rte_eth_tx_burst(test_params->bonded_port_id, 0, &pkt_burst[0][0],
>-			burst_size) != (burst_size * slave_count)) {
>+			burst_size) != burst_size) {
> 		printf("rte_eth_tx_burst failed\n");
> 		return -1;
> 	}
>diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>index 70123fc..ae9726e 100644
>--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
>@@ -101,7 +101,7 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct
>rte_mbuf **bufs,
> 	uint8_t num_of_slaves;
> 	uint8_t slaves[RTE_MAX_ETHPORTS];
> 
>-	uint16_t num_tx_total = 0;
>+	uint16_t num_tx_total = 0, num_tx_slave;
> 
> 	static int slave_idx = 0;
> 	int i, cs_idx = 0;
>@@ -130,9 +130,17 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct
>rte_mbuf **bufs,
> 
> 	/* Send packet burst on each slave device */
> 	for (i = 0; i < num_of_slaves; i++)
>-		if (slave_nb_pkts[i] > 0)
>-			num_tx_total += rte_eth_tx_burst(slaves[i],
>+		if (slave_nb_pkts[i] > 0) {
>+			num_tx_slave = rte_eth_tx_burst(slaves[i],
> 					bd_tx_q->queue_id, slave_bufs[i], slave_nb_pkts[i]);
>+			num_tx_total += num_tx_slave;
>+
>+			/* if tx burst fails, free unsent mbufs */
>+			while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
>+				rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
>+				num_tx_slave++;
>+			}
>+		}
> 
> 	return num_tx_total;
> }
>@@ -283,7 +291,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct
>rte_mbuf **bufs,
> 	uint8_t num_of_slaves;
> 	uint8_t slaves[RTE_MAX_ETHPORTS];
> 
>-	uint16_t num_tx_total = 0;
>+	uint16_t num_tx_total = 0, num_tx_slave = 0;
> 
> 	int i, op_slave_id;
> 
>@@ -315,11 +323,19 @@ bond_ethdev_tx_burst_balance(void *queue, struct
>rte_mbuf **bufs,
> 	/* Send packet burst on each slave device */
> 	for (i = 0; i < num_of_slaves; i++) {
> 		if (slave_nb_pkts[i] > 0) {
>-			num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
>+			num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
> 					slave_bufs[i], slave_nb_pkts[i]);
>+			num_tx_total += num_tx_slave;
>+
>+			/* if tx burst fails, free unsent mbufs */
>+			while (unlikely(num_tx_slave < slave_nb_pkts[i])) {
>+				rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
>+				num_tx_slave++;
>+			}
> 		}
> 	}
> 
>+
> 	return num_tx_total;
> }
> 
>@@ -333,7 +349,7 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct
>rte_mbuf **bufs,
> 	uint8_t num_of_slaves;
> 	uint8_t slaves[RTE_MAX_ETHPORTS];
> 
>-	uint16_t num_tx_total = 0;
>+	uint16_t num_tx_slave = 0, max_tx_pkts = 0;
> 
> 	int i;
> 
>@@ -354,11 +370,21 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct
>rte_mbuf **bufs,
> 		rte_mbuf_refcnt_update(bufs[i], num_of_slaves - 1);
> 
> 	/* Transmit burst on each active slave */
>-	for (i = 0; i < num_of_slaves; i++)
>-		num_tx_total += rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
>-				bufs, nb_pkts);
>+	for (i = 0; i < num_of_slaves; i++) {
>+		num_tx_slave = rte_eth_tx_burst(slaves[i], bd_tx_q->queue_id,
>+					bufs, nb_pkts);
> 
>-	return num_tx_total;
>+		if (max_tx_pkts < num_tx_slave)
>+			max_tx_pkts = num_tx_slave;
>+
>+		/* if tx burst fails, free unsent mbufs */
>+		while (unlikely(num_tx_slave < nb_pkts)) {
>+			rte_pktmbuf_free(bufs[num_tx_slave]);
>+			num_tx_slave++;
>+		}
>+	}
>+
>+	return max_tx_pkts;
> }
> 
> void
>-- 
>1.7.0.7
>

^ permalink raw reply	[flat|nested] 93+ messages in thread

end of thread, other threads:[~2014-11-25 11:10 UTC | newest]

Thread overview: 93+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19 13:51 [dpdk-dev] [PATCH 0/6] link bonding Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 1/6] bond: link status interrupt support Declan Doherty
2014-08-20 20:24   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 2/6] bond: removing switch statement from rx burst method Declan Doherty
2014-08-20 20:25   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-08-20 20:25   ` Sanford, Robert
2014-08-19 13:51 ` [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 5/6] test app: adding support for generating variable sized packets Declan Doherty
2014-08-19 13:51 ` [dpdk-dev] [PATCH 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-08-22  7:41 ` [dpdk-dev] [PATCH 0/6] link bonding Jiajia, SunX
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 " Declan Doherty
2014-09-02 13:31   ` De Lara Guarch, Pablo
2014-09-02 18:15   ` Stephen Hemminger
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 1/6] bond: link status interrupt support Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 2/6] bond: removing switch statement from rx burst method Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 3/6] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-09-02  9:22   ` Doherty, Declan
2014-09-02  9:31     ` Thomas Monjalon
2014-09-23 13:18   ` [dpdk-dev] [PATCH v3 0/5] link bonding Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 1/5] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 2/5] test app: adding support for generating variable sized packet Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 3/5] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 4/5] bond: lsc polling support Declan Doherty
2014-09-24 13:16       ` Ananyev, Konstantin
2014-09-23 13:18     ` [dpdk-dev] [PATCH v3 5/5] bond: unit test test macro refactor Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 5/6] test app: adding support for generating variable sized packets Declan Doherty
2014-09-01  8:31 ` [dpdk-dev] [PATCH v2 6/6] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-30  9:57 ` [dpdk-dev] [PATCH v4 0/8] link bonding Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 1/8] bond: link status interrupt support Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-10-13 15:29     ` De Lara Guarch, Pablo
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 5/8] test app: adding support for generating variable sized packet bursts Declan Doherty
2014-10-24  3:22     ` Liang, Cunming
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 7/8] bond: lsc polling support Declan Doherty
2014-09-30  9:57   ` [dpdk-dev] [PATCH v4 8/8] bond: unit test test macro refactor Declan Doherty
2014-10-08  8:49   ` [dpdk-dev] [PATCH v4 0/8] link bonding Jiajia, SunX
2014-10-09 19:20   ` De Lara Guarch, Pablo
2014-10-14 12:59   ` [dpdk-dev] [PATCH v5 " Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 1/8] bond: link status interrupt support Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 5/8] test app: adding support for generating variable sized packet Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 7/8] bond: lsc polling support Declan Doherty
2014-10-14 12:59     ` [dpdk-dev] [PATCH v5 8/8] bond: unit test test macro refactor Declan Doherty
2014-10-14 15:59     ` [dpdk-dev] [PATCH v5 0/8] link bonding De Lara Guarch, Pablo
2014-11-05  3:10     ` Jiajia, SunX
2014-11-07 12:22     ` [dpdk-dev] [PATCH v6 " Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 1/8] bond: link status interrupt support Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 2/8] bond: removing switch statement from rx burst method Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 3/8] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 4/8] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 5/8] test app: adding support for generating variable sized packet Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 6/8] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 7/8] bond: lsc polling support Declan Doherty
2014-11-07 12:22       ` [dpdk-dev] [PATCH v6 8/8] bond: unit test test macro refactor Declan Doherty
2014-11-07 16:40       ` [dpdk-dev] [PATCH v6 0/8] link bonding De Lara Guarch, Pablo
2014-11-21 17:07         ` Doherty, Declan
2014-11-21 18:36           ` Thomas Monjalon
2014-11-23 13:40             ` Thomas Monjalon
2014-11-21  8:59       ` Jiajia, SunX
2014-11-24 12:27       ` [dpdk-dev] [PATCH v7 0/7] " Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 1/7] bond: link status interrupt support Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 2/7] bond: removing switch statement from rx burst method Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 6/7] bond: lsc polling support Declan Doherty
2014-11-24 12:27         ` [dpdk-dev] [PATCH v7 7/7] bond: unit test test macro refactor Declan Doherty
2014-11-24 15:35         ` [dpdk-dev] [PATCH v7 0/7] link bonding Thomas Monjalon
2014-11-24 16:24           ` Doherty, Declan
2014-11-24 17:53             ` Thomas Monjalon
2014-11-24 16:33         ` [dpdk-dev] [PATCH v8 " Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 1/7] bond: link status interrupt support Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 2/7] bond: removing switch statement from rx burst method Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 3/7] bond: fix naming inconsistency in tx_burst_round_robin Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 4/7] bond: free mbufs if transmission fails in bonding tx_burst functions Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 5/7] testpmd: adding parameter to reconfig method to set socket_id when adding new port to portlist Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 6/7] bond: lsc polling support Declan Doherty
2014-11-24 16:33           ` [dpdk-dev] [PATCH v8 7/7] bond: unit test test macro refactor Declan Doherty
2014-11-24 18:32           ` [dpdk-dev] [PATCH v8 0/7] link bonding Thomas Monjalon
2014-11-24 18:51             ` Thomas Monjalon
2014-11-24 20:54           ` Thomas Monjalon
2014-11-25 10:56             ` Jastrzebski, MichalX K
2014-11-25 11:20               ` Thomas Monjalon
2014-08-20 20:54 [dpdk-dev] [PATCH 4/6] bond: free mbufs if transmission fails in bonding tx_burst functions Sanford, Robert
2014-08-29 15:36 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).