summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2018-10-19 13:20:12 -0700
committerDamjan Marion <dmarion@me.com>2018-10-20 09:00:39 +0000
commitcef69caf1dcd3a2452d38c5fa516d0b61b56c34a (patch)
tree33b88f4fc6ff98e1078dc56e85817bf18975786b /src
parenteb1744f1593bf44101bf46b8e3496063a3fb890c (diff)
dpdk: use rx/tx_offload_names to format
Rather than keeping our own list of offload capabalities, use the function in 18.08 or later to decode the value. Also, introduce a formatter to convert to lower case because DPDK API returns upper case names. Change-Id: I87546fa2bec67f8a8b44288f5994514114cb6faf Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/device/format.c91
1 files changed, 53 insertions, 38 deletions
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index 28e8f0a445c..4494895f380 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -69,42 +69,6 @@
_(ETH_RSS_GENEVE, "geneve") \
_(ETH_RSS_NVGRE, "nvgre")
-
-#define foreach_dpdk_rx_offload_caps \
- _(DEV_RX_OFFLOAD_VLAN_STRIP, "vlan-strip") \
- _(DEV_RX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \
- _(DEV_RX_OFFLOAD_UDP_CKSUM , "udp-cksum") \
- _(DEV_RX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \
- _(DEV_RX_OFFLOAD_TCP_LRO , "rcp-lro") \
- _(DEV_RX_OFFLOAD_QINQ_STRIP, "qinq-strip") \
- _(DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM, "outer-ipv4-cksum") \
- _(DEV_RX_OFFLOAD_MACSEC_STRIP, "macsec-strip") \
- _(DEV_RX_OFFLOAD_HEADER_SPLIT, "header-split") \
- _(DEV_RX_OFFLOAD_VLAN_FILTER, "vlan-filter") \
- _(DEV_RX_OFFLOAD_VLAN_EXTEND, "vlan-extend") \
- _(DEV_RX_OFFLOAD_JUMBO_FRAME, "jumbo-frame") \
- _(DEV_RX_OFFLOAD_CRC_STRIP, "crc-strip") \
- _(DEV_RX_OFFLOAD_SCATTER, "scatter") \
- _(DEV_RX_OFFLOAD_TIMESTAMP, "timestamp") \
- _(DEV_RX_OFFLOAD_SECURITY, "security")
-
-#define foreach_dpdk_tx_offload_caps \
- _(DEV_TX_OFFLOAD_VLAN_INSERT, "vlan-insert") \
- _(DEV_TX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \
- _(DEV_TX_OFFLOAD_UDP_CKSUM , "udp-cksum") \
- _(DEV_TX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \
- _(DEV_TX_OFFLOAD_SCTP_CKSUM , "sctp-cksum") \
- _(DEV_TX_OFFLOAD_TCP_TSO , "tcp-tso") \
- _(DEV_TX_OFFLOAD_UDP_TSO , "udp-tso") \
- _(DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, "outer-ipv4-cksum") \
- _(DEV_TX_OFFLOAD_QINQ_INSERT, "qinq-insert") \
- _(DEV_TX_OFFLOAD_VXLAN_TNL_TSO, "vxlan-tnl-tso") \
- _(DEV_TX_OFFLOAD_GRE_TNL_TSO, "gre-tnl-tso") \
- _(DEV_TX_OFFLOAD_IPIP_TNL_TSO, "ipip-tnl-tso") \
- _(DEV_TX_OFFLOAD_GENEVE_TNL_TSO, "geneve-tnl-tso") \
- _(DEV_TX_OFFLOAD_MACSEC_INSERT, "macsec-insert") \
- _(DEV_TX_OFFLOAD_MT_LOCKFREE, "mt-lockfree") \
-
#define foreach_dpdk_pkt_rx_offload_flag \
_ (PKT_RX_VLAN, "RX packet is a 802.1q VLAN packet") \
_ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \
@@ -458,16 +422,59 @@ format_dpdk_rss_hf_name (u8 * s, va_list * args)
foreach_dpdk_rss_hf return s;
}
+#undef _
+
+/* Convert to all lower case e.g "VLAN_STRIP" -> "vlan-strip"
+ Works for both vector names and null terminated c strings. */
+static u8 *
+format_offload (u8 * s, va_list * va)
+{
+ u8 *id = va_arg (*va, u8 *);
+ uword i, l;
+
+ l = ~0;
+ if (clib_mem_is_vec (id))
+ l = vec_len (id);
+
+ if (id)
+ for (i = 0; id[i] != 0 && i < l; i++)
+ {
+ u8 c = id[i];
+
+ if (c == '_')
+ c = '-';
+ else
+ c = tolower (c);
+ vec_add1 (s, c);
+ }
+
+ return s;
+}
+
+#define _(v, func) \
+if (bitmap & v) { \
+ if (format_get_indent (s) > 72) \
+ s = format(s,"\n%U", format_white_space, indent); \
+ s = format(s, "%U ", format_offload, func (v)); \
+}
+
u8 *
format_dpdk_rx_offload_caps (u8 * s, va_list * args)
{
u64 bitmap = va_arg (*args, u32);
u32 indent = format_get_indent (s);
+ uword i;
if (!bitmap)
return format (s, "none");
- foreach_dpdk_rx_offload_caps return s;
+ for (i = 0; i < 64; i++)
+ {
+ u64 mask = (u64) 1 << i;
+
+ _(mask, rte_eth_dev_rx_offload_name);
+ }
+ return s;
}
u8 *
@@ -475,10 +482,18 @@ format_dpdk_tx_offload_caps (u8 * s, va_list * args)
{
u64 bitmap = va_arg (*args, u32);
u32 indent = format_get_indent (s);
+ uword i;
+
if (!bitmap)
return format (s, "none");
- foreach_dpdk_tx_offload_caps return s;
+ for (i = 0; i < 64; i++)
+ {
+ u64 mask = (u64) 1 << i;
+
+ _(mask, rte_eth_dev_tx_offload_name);
+ }
+ return s;
}
#undef _