diff mbox

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

Message ID 1464853550-9104-1-git-send-email-matias.elo@nokia.com
State Accepted
Commit 8f3919ecf286af1b5165a37bc0b3e8c6cf822a48
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) June 2, 2016, 7:45 a.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>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/pktio/netmap.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Maxim Uvarov June 2, 2016, 6:24 p.m. UTC | #1
Merged,

Thanks.

On 06/02/16 10:45, Matias Elo 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>
> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   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;
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;