[dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list

2016-10-07 Thread Olivier Matz
Hi Pablo,

On 10/07/2016 05:51 AM, De Lara Guarch, Pablo wrote:
> 
> 
>> -Original Message-
>> From: Olivier Matz [mailto:olivier.matz at 6wind.com]
>> Sent: Thursday, October 06, 2016 1:43 AM
>> To: dev at dpdk.org; De Lara Guarch, Pablo
>> Subject: [PATCH v3] mbuf: add function to dump ol flag list
>>
>> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
>> can dump one flag, or set of flag that are part of the same mask (ex:
>> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed
>> to
>> dump the list of flags contained in mbuf->ol_flags.
>>
>> This commit introduce new functions to do that. Similarly to the packet
>> type dump functions, the goal is to factorize the code that could be
>> used in several applications and reduce the risk of desynchronization
>> between the flags and the dump functions.
>>
>> Signed-off-by: Olivier Matz 
> 
> Hi Olivier,
> 
> Sorry, I missed a typo in this patch: "ouput" -> "output".
> 
> Also, check-git-log.sh is complaining about two patches:
> 
> Wrong headline lowercase:
> app/testpmd: dump rx flags in csum engine
> app/testpmd: display rx port in csum engine
> 
> Lastly, could you send another version of the patchset (including patches 
> without any modifications).
> In my opinion, it is a bit difficult to apply the patchset, because Patchwork 
> doesn't tell me
> that this patch is the first patch of the patchset.

Thank you for the review. I'll fix all these issue and send the whole
patchset again (will be called v5 to avoid confusion with separate
patches). I didn't want to spam the list with the full patchset for
these minor fixes, but you're right it's not that clear.

Regards,
Olivier


[dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list

2016-10-07 Thread De Lara Guarch, Pablo


> -Original Message-
> From: Olivier Matz [mailto:olivier.matz at 6wind.com]
> Sent: Thursday, October 06, 2016 1:43 AM
> To: dev at dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v3] mbuf: add function to dump ol flag list
> 
> The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
> can dump one flag, or set of flag that are part of the same mask (ex:
> PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed
> to
> dump the list of flags contained in mbuf->ol_flags.
> 
> This commit introduce new functions to do that. Similarly to the packet
> type dump functions, the goal is to factorize the code that could be
> used in several applications and reduce the risk of desynchronization
> between the flags and the dump functions.
> 
> Signed-off-by: Olivier Matz 

Hi Olivier,

Sorry, I missed a typo in this patch: "ouput" -> "output".

Also, check-git-log.sh is complaining about two patches:

Wrong headline lowercase:
app/testpmd: dump rx flags in csum engine
app/testpmd: display rx port in csum engine

Lastly, could you send another version of the patchset (including patches 
without any modifications).
In my opinion, it is a bit difficult to apply the patchset, because Patchwork 
doesn't tell me
that this patch is the first patch of the patchset.

The rest of the patches look ok to me.

Thanks,
Pablo


[dpdk-dev] [PATCH v3] mbuf: add function to dump ol flag list

2016-10-06 Thread Olivier Matz
The functions rte_get_rx_ol_flag_name() and rte_get_tx_ol_flag_name()
can dump one flag, or set of flag that are part of the same mask (ex:
PKT_TX_UDP_CKSUM, part of PKT_TX_L4_MASK). But they are not designed to
dump the list of flags contained in mbuf->ol_flags.

This commit introduce new functions to do that. Similarly to the packet
type dump functions, the goal is to factorize the code that could be
used in several applications and reduce the risk of desynchronization
between the flags and the dump functions.

Signed-off-by: Olivier Matz 
---

v2 -> v3:
- Move return type on a separate line in function definitions

 doc/guides/rel_notes/release_16_11.rst |  5 ++
 lib/librte_mbuf/rte_mbuf.c | 93 ++
 lib/librte_mbuf/rte_mbuf.h | 28 ++
 lib/librte_mbuf/rte_mbuf_version.map   |  2 +
 4 files changed, 128 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_11.rst 
b/doc/guides/rel_notes/release_16_11.rst
index 40c09ca..3d3c417 100644
--- a/doc/guides/rel_notes/release_16_11.rst
+++ b/doc/guides/rel_notes/release_16_11.rst
@@ -50,6 +50,11 @@ New Features

   Added new functions ``rte_get_ptype_*()`` to dump a packet type as a string.

+* **Added functions to dump the offload flags as a string.**
+
+  Added two new functions ``rte_get_rx_ol_flag_list()`` and
+  ``rte_get_tx_ol_flag_list()`` to dump offload flags as a string.
+
 Resolved Issues
 ---

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 37fd72b..37691ca 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -317,6 +317,54 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
}
 }

+struct flag_mask {
+   uint64_t flag;
+   uint64_t mask;
+   const char *default_name;
+};
+
+/* write the list of rx ol flags in buffer buf */
+int
+rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+   const struct flag_mask rx_flags[] = {
+   { PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
+   { PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
+   { PKT_RX_FDIR, PKT_RX_FDIR, NULL },
+   { PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
+   { PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
+   { PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
+   { PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
+   { PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
+   { PKT_RX_IEEE1588_TMST, PKT_RX_IEEE1588_TMST, NULL },
+   { PKT_RX_QINQ_STRIPPED, PKT_RX_QINQ_STRIPPED, NULL },
+   };
+   const char *name;
+   unsigned int i;
+   int ret;
+
+   if (buflen == 0)
+   return -1;
+
+   buf[0] = '\0';
+   for (i = 0; i < RTE_DIM(rx_flags); i++) {
+   if ((mask & rx_flags[i].mask) != rx_flags[i].flag)
+   continue;
+   name = rte_get_rx_ol_flag_name(rx_flags[i].flag);
+   if (name == NULL)
+   name = rx_flags[i].default_name;
+   ret = snprintf(buf, buflen, "%s ", name);
+   if (ret < 0)
+   return -1;
+   if ((size_t)ret >= buflen)
+   return -1;
+   buf += ret;
+   buflen -= ret;
+   }
+
+   return 0;
+}
+
 /*
  * Get the name of a TX offload flag. Must be kept synchronized with flag
  * definitions in rte_mbuf.h.
@@ -339,3 +387,48 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
default: return NULL;
}
 }
+
+/* write the list of tx ol flags in buffer buf */
+int
+rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
+{
+   const struct flag_mask tx_flags[] = {
+   { PKT_TX_VLAN_PKT, PKT_TX_VLAN_PKT, NULL },
+   { PKT_TX_IP_CKSUM, PKT_TX_IP_CKSUM, NULL },
+   { PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK, NULL },
+   { PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK, NULL },
+   { PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK, NULL },
+   { PKT_TX_L4_NO_CKSUM, PKT_TX_L4_MASK, "PKT_TX_L4_NO_CKSUM" },
+   { PKT_TX_IEEE1588_TMST, PKT_TX_IEEE1588_TMST, NULL },
+   { PKT_TX_TCP_SEG, PKT_TX_TCP_SEG, NULL },
+   { PKT_TX_IPV4, PKT_TX_IPV4, NULL },
+   { PKT_TX_IPV6, PKT_TX_IPV6, NULL },
+   { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM, NULL },
+   { PKT_TX_OUTER_IPV4, PKT_TX_OUTER_IPV4, NULL },
+   { PKT_TX_OUTER_IPV6, PKT_TX_OUTER_IPV6, NULL },
+   };
+   const char *name;
+   unsigned int i;
+   int ret;
+
+   if (buflen == 0)
+   return -1;
+
+   buf[0] = '\0';
+   for (i = 0; i < RTE_DIM(tx_flags); i++) {
+   if ((mask & tx_flags[i].mask) != tx_flags[i].flag)
+   continue;
+   name = rte_get_tx_ol_flag_name(tx_flags[i].flag);
+   if