diff mbox

[1/4] linux-gen: netmap: handle modified _odp_packet_cls_enq() return values correctly

Message ID 1464784423-7713-1-git-send-email-matias.elo@nokia.com
State Superseded
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) June 1, 2016, 12:33 p.m. UTC
Do not increase the count of received packets if classifier
already handled the packet. Fixes odp_classifier example
crashing with netmap pktio.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 platform/linux-generic/pktio/netmap.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Bill Fischofer June 1, 2016, 6:57 p.m. UTC | #1
For this series:

Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>

On Wed, Jun 1, 2016 at 7:33 AM, Matias Elo <matias.elo@nokia.com> wrote:

> Do not increase the count of received packets if classifier
> already handled the packet. Fixes odp_classifier example
> crashing with netmap pktio.
>
> Signed-off-by: Matias Elo <matias.elo@nokia.com>
> ---
>  platform/linux-generic/pktio/netmap.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/platform/linux-generic/pktio/netmap.c
> b/platform/linux-generic/pktio/netmap.c
> index 1042fd1..820629c 100644
> --- a/platform/linux-generic/pktio/netmap.c
> +++ b/platform/linux-generic/pktio/netmap.c
> @@ -585,7 +585,7 @@ static int netmap_stop(pktio_entry_t *pktio_entry
> ODP_UNUSED)
>   * @param len            Netmap buffer length
>   * @param ts             Pointer to pktin timestamp
>   *
> - * @retval 0 on success
> + * @retval Number of created packets
>   * @retval <0 on failure
>   */
>  static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry,
> @@ -637,7 +637,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t
> *pktio_entry,
>                 *pkt_out = pkt;
>         }
>
> -       return 0;
> +       return 1;
>  }
>
>  static inline int netmap_recv_desc(pktio_entry_t *pktio_entry,
> @@ -650,6 +650,7 @@ static inline int netmap_recv_desc(pktio_entry_t
> *pktio_entry,
>         char *buf;
>         uint32_t slot_id;
>         int i;
> +       int ret;
>         int ring_id = desc->cur_rx_ring;
>         int num_rx = 0;
>         int num_rings = desc->last_rx_ring - desc->first_rx_ring + 1;
> @@ -674,10 +675,11 @@ static inline int netmap_recv_desc(pktio_entry_t
> *pktio_entry,
>
>                         odp_prefetch(buf);
>
> -                       if (!netmap_pkt_to_odp(pktio_entry,
> &pkt_table[num_rx],
> -                                              buf,
> ring->slot[slot_id].len,
> -                                              ts))
> -                               num_rx++;
> +                       ret = netmap_pkt_to_odp(pktio_entry,
> &pkt_table[num_rx],
> +                                               buf,
> ring->slot[slot_id].len,
> +                                               ts);
> +                       if (ret > 0)
> +                               num_rx += ret;
>
>                         ring->cur = nm_ring_next(ring, slot_id);
>                         ring->head = ring->cur;
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
index 1042fd1..820629c 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -585,7 +585,7 @@  static int netmap_stop(pktio_entry_t *pktio_entry ODP_UNUSED)
  * @param len            Netmap buffer length
  * @param ts             Pointer to pktin timestamp
  *
- * @retval 0 on success
+ * @retval Number of created packets
  * @retval <0 on failure
  */
 static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry,
@@ -637,7 +637,7 @@  static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry,
 		*pkt_out = pkt;
 	}
 
-	return 0;
+	return 1;
 }
 
 static inline int netmap_recv_desc(pktio_entry_t *pktio_entry,
@@ -650,6 +650,7 @@  static inline int netmap_recv_desc(pktio_entry_t *pktio_entry,
 	char *buf;
 	uint32_t slot_id;
 	int i;
+	int ret;
 	int ring_id = desc->cur_rx_ring;
 	int num_rx = 0;
 	int num_rings = desc->last_rx_ring - desc->first_rx_ring + 1;
@@ -674,10 +675,11 @@  static inline int netmap_recv_desc(pktio_entry_t *pktio_entry,
 
 			odp_prefetch(buf);
 
-			if (!netmap_pkt_to_odp(pktio_entry, &pkt_table[num_rx],
-					       buf, ring->slot[slot_id].len,
-					       ts))
-				num_rx++;
+			ret = netmap_pkt_to_odp(pktio_entry, &pkt_table[num_rx],
+						buf, ring->slot[slot_id].len,
+						ts);
+			if (ret > 0)
+				num_rx += ret;
 
 			ring->cur = nm_ring_next(ring, slot_id);
 			ring->head = ring->cur;