diff mbox

[v2] linux-generic: pktio: print out the name of pktio used

Message ID 1447264278-3536-1-git-send-email-zoltan.kiss@linaro.org
State Superseded
Headers show

Commit Message

Zoltan Kiss Nov. 11, 2015, 5:51 p.m. UTC
For debug purposes, otherwise it's not trivial to figure out which pktio was
successful.

Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
--

v2:
- change the string for loopback and socket interfaces
- also add it to odp_pktio_print()

Comments

Stuart Haslam Nov. 13, 2015, 4:18 p.m. UTC | #1
On Wed, Nov 11, 2015 at 05:51:18PM +0000, Zoltan Kiss wrote:
> For debug purposes, otherwise it's not trivial to figure out which pktio was
> successful.
> 
> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
> --
> 
> v2:
> - change the string for loopback and socket interfaces
> - also add it to odp_pktio_print()
> 
> diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
> index 1a1118c..a46c6fe 100644
> --- a/platform/linux-generic/include/odp_packet_io_internal.h
> +++ b/platform/linux-generic/include/odp_packet_io_internal.h
> @@ -100,6 +100,7 @@ typedef struct {
>  } pktio_table_t;
>  
>  typedef struct pktio_if_ops {
> +	const char *name;
>  	int (*init)(void);
>  	int (*term)(void);
>  	int (*open)(odp_pktio_t pktio, pktio_entry_t *pktio_entry,
> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
> index 3ef400f..e542af3 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -229,6 +229,8 @@ static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
>  
>  		if (!ret) {
>  			pktio_entry->s.ops = pktio_if_ops[pktio_if];
> +			ODP_ERR("%s uses %s\n",
> +				dev, pktio_if_ops[pktio_if]->name);

Should be ODP_DBG (it was in v1).

>  			break;
>  		}
>  	}
> @@ -845,6 +847,8 @@ void odp_pktio_print(odp_pktio_t id)
>  	len += snprintf(&str[len], n - len,
>  			"  name         %s\n", entry->s.name);
>  	len += snprintf(&str[len], n - len,
> +			"  type         %s\n", entry->s.ops->name);
> +	len += snprintf(&str[len], n - len,
>  			"  state        %s\n",
>  			entry->s.state ==  STATE_START ? "start" :
>  		       (entry->s.state ==  STATE_STOP ? "stop" : "unknown"));
> diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
> index ce19add..44da917 100644
> --- a/platform/linux-generic/pktio/loop.c
> +++ b/platform/linux-generic/pktio/loop.c
> @@ -108,6 +108,7 @@ static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry)
>  }
>  
>  const pktio_if_ops_t loopback_pktio_ops = {
> +	.name = "loop",
>  	.init = NULL,
>  	.term = NULL,
>  	.open = loopback_open,
> diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
> index 794c82e..bc4ab1c 100644
> --- a/platform/linux-generic/pktio/netmap.c
> +++ b/platform/linux-generic/pktio/netmap.c
> @@ -307,6 +307,7 @@ static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry)
>  }
>  
>  const pktio_if_ops_t netmap_pktio_ops = {
> +	.name = "netmap",
>  	.init = NULL,
>  	.term = NULL,
>  	.open = netmap_open,
> diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c
> index 0817bf5..94b506d 100644
> --- a/platform/linux-generic/pktio/pcap.c
> +++ b/platform/linux-generic/pktio/pcap.c
> @@ -370,6 +370,7 @@ static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry)
>  }
>  
>  const pktio_if_ops_t pcap_pktio_ops = {
> +	.name = "pcap",
>  	.open = pcapif_init,
>  	.close = pcapif_close,
>  	.recv = pcapif_recv_pkt,
> diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
> index 5f5e0ae..56b0a8b 100644
> --- a/platform/linux-generic/pktio/socket.c
> +++ b/platform/linux-generic/pktio/socket.c
> @@ -468,6 +468,7 @@ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry)
>  }
>  
>  const pktio_if_ops_t sock_mmsg_pktio_ops = {
> +	.name = "socket",
>  	.init = NULL,
>  	.term = NULL,
>  	.open = sock_mmsg_open,
> diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
> index 79ff82d..3a51179 100644
> --- a/platform/linux-generic/pktio/socket_mmap.c
> +++ b/platform/linux-generic/pktio/socket_mmap.c
> @@ -519,6 +519,7 @@ static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry)
>  }
>  
>  const pktio_if_ops_t sock_mmap_pktio_ops = {
> +	.name = "socket_mmap",
>  	.init = NULL,
>  	.term = NULL,
>  	.open = sock_mmap_open,
Zoltan Kiss Nov. 16, 2015, 5:39 p.m. UTC | #2
On 13/11/15 16:18, Stuart Haslam wrote:
>> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
>> >index 3ef400f..e542af3 100644
>> >--- a/platform/linux-generic/odp_packet_io.c
>> >+++ b/platform/linux-generic/odp_packet_io.c
>> >@@ -229,6 +229,8 @@ static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
>> >
>> >  		if (!ret) {
>> >  			pktio_entry->s.ops = pktio_if_ops[pktio_if];
>> >+			ODP_ERR("%s uses %s\n",
>> >+				dev, pktio_if_ops[pktio_if]->name);
> Should be ODP_DBG (it was in v1).
>

I've fixed it in v3
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 1a1118c..a46c6fe 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -100,6 +100,7 @@  typedef struct {
 } pktio_table_t;
 
 typedef struct pktio_if_ops {
+	const char *name;
 	int (*init)(void);
 	int (*term)(void);
 	int (*open)(odp_pktio_t pktio, pktio_entry_t *pktio_entry,
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 3ef400f..e542af3 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -229,6 +229,8 @@  static odp_pktio_t setup_pktio_entry(const char *dev, odp_pool_t pool,
 
 		if (!ret) {
 			pktio_entry->s.ops = pktio_if_ops[pktio_if];
+			ODP_ERR("%s uses %s\n",
+				dev, pktio_if_ops[pktio_if]->name);
 			break;
 		}
 	}
@@ -845,6 +847,8 @@  void odp_pktio_print(odp_pktio_t id)
 	len += snprintf(&str[len], n - len,
 			"  name         %s\n", entry->s.name);
 	len += snprintf(&str[len], n - len,
+			"  type         %s\n", entry->s.ops->name);
+	len += snprintf(&str[len], n - len,
 			"  state        %s\n",
 			entry->s.state ==  STATE_START ? "start" :
 		       (entry->s.state ==  STATE_STOP ? "stop" : "unknown"));
diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index ce19add..44da917 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -108,6 +108,7 @@  static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry)
 }
 
 const pktio_if_ops_t loopback_pktio_ops = {
+	.name = "loop",
 	.init = NULL,
 	.term = NULL,
 	.open = loopback_open,
diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
index 794c82e..bc4ab1c 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -307,6 +307,7 @@  static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry)
 }
 
 const pktio_if_ops_t netmap_pktio_ops = {
+	.name = "netmap",
 	.init = NULL,
 	.term = NULL,
 	.open = netmap_open,
diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c
index 0817bf5..94b506d 100644
--- a/platform/linux-generic/pktio/pcap.c
+++ b/platform/linux-generic/pktio/pcap.c
@@ -370,6 +370,7 @@  static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry)
 }
 
 const pktio_if_ops_t pcap_pktio_ops = {
+	.name = "pcap",
 	.open = pcapif_init,
 	.close = pcapif_close,
 	.recv = pcapif_recv_pkt,
diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c
index 5f5e0ae..56b0a8b 100644
--- a/platform/linux-generic/pktio/socket.c
+++ b/platform/linux-generic/pktio/socket.c
@@ -468,6 +468,7 @@  static int sock_promisc_mode_get(pktio_entry_t *pktio_entry)
 }
 
 const pktio_if_ops_t sock_mmsg_pktio_ops = {
+	.name = "socket",
 	.init = NULL,
 	.term = NULL,
 	.open = sock_mmsg_open,
diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c
index 79ff82d..3a51179 100644
--- a/platform/linux-generic/pktio/socket_mmap.c
+++ b/platform/linux-generic/pktio/socket_mmap.c
@@ -519,6 +519,7 @@  static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry)
 }
 
 const pktio_if_ops_t sock_mmap_pktio_ops = {
+	.name = "socket_mmap",
 	.init = NULL,
 	.term = NULL,
 	.open = sock_mmap_open,