Type: improvement
This patch implements support to show host interface offload
flags at the time of creation. It also shows host interface
offload flags at the time of calling given function through
'show hardware'.
Before:
Host Interface Offload:
creation time:
rx checksum
tx checksum
tcp segmentation offload
generic segemanttaion offload
now:
rx checksum
tx checksum
tcp segmentation offload
generic segemanttaion offload
After changing the offloads on the veth using ethtool command ('ethtool -K veth1 rx off tx off'):
Host Interface Offload:
creation time:
rx checksum
tx checksum
tcp segmentation offload
generic segemanttaion offload
now:
generic segemanttaion offload
Signed-off-by: Mohsin Kazmi <[email protected]>
Change-Id: Ia38d35e7a70206781afad42f0333e47bac8fedc9
/*defined in net/if.h but clashes with dpdk headers */
unsigned int if_nametoindex (const char *ifname);
-#define AF_PACKET_OFFLOAD_FLAG_RXCKSUM (1 << 0)
-#define AF_PACKET_OFFLOAD_FLAG_TXCKSUM (1 << 1)
-#define AF_PACKET_OFFLOAD_FLAG_SG (1 << 2)
-#define AF_PACKET_OFFLOAD_FLAG_TSO (1 << 3)
-#define AF_PACKET_OFFLOAD_FLAG_UFO (1 << 4)
-#define AF_PACKET_OFFLOAD_FLAG_GSO (1 << 5)
-#define AF_PACKET_OFFLOAD_FLAG_GRO (1 << 6)
-
-#define AF_PACKET_OFFLOAD_FLAG_MASK \
- (AF_PACKET_OFFLOAD_FLAG_RXCKSUM | AF_PACKET_OFFLOAD_FLAG_TXCKSUM | \
- AF_PACKET_OFFLOAD_FLAG_SG | AF_PACKET_OFFLOAD_FLAG_TSO | \
- AF_PACKET_OFFLOAD_FLAG_UFO | AF_PACKET_OFFLOAD_FLAG_GSO | \
- AF_PACKET_OFFLOAD_FLAG_GRO)
-
#define AF_PACKET_IOCTL(fd, a, ...) \
if (ioctl (fd, a, __VA_ARGS__) < 0) \
{ \
goto done; \
}
-static u32
+u32
af_packet_get_if_capabilities (u8 *host_if_name)
{
struct ifreq ifr;
AF_PACKET_IF_FLAGS_VERSION_2 = 8,
} af_packet_if_flags_t;
+#define foreach_af_packet_offload_flag \
+ _ (RXCKSUM, 0, "rx checksum") \
+ _ (TXCKSUM, 1, "tx checksum") \
+ _ (SG, 2, "scatter-gather") \
+ _ (TSO, 3, "tcp segmentation offload") \
+ _ (UFO, 4, "udp fragmentation offload") \
+ _ (GSO, 5, "generic segmentation offload") \
+ _ (GRO, 6, "generic receive offload")
+
+typedef enum
+{
+#define _(o, n, s) AF_PACKET_OFFLOAD_FLAG_##o = (1 << n),
+ foreach_af_packet_offload_flag
+#undef _
+} af_packet_offload_flag_t;
+
+#define AF_PACKET_OFFLOAD_FLAG_MASK \
+ (AF_PACKET_OFFLOAD_FLAG_RXCKSUM | AF_PACKET_OFFLOAD_FLAG_TXCKSUM | \
+ AF_PACKET_OFFLOAD_FLAG_SG | AF_PACKET_OFFLOAD_FLAG_TSO | \
+ AF_PACKET_OFFLOAD_FLAG_UFO | AF_PACKET_OFFLOAD_FLAG_GSO | \
+ AF_PACKET_OFFLOAD_FLAG_GRO)
+
typedef struct
{
u32 sw_if_index;
u8 is_qdisc_bypass_enabled;
u8 is_fanout_enabled;
int *fds;
- u32 host_interface_oflags;
+ af_packet_offload_flag_t host_interface_oflags;
} af_packet_if_t;
typedef struct
int af_packet_set_l4_cksum_offload (u32 sw_if_index, u8 set);
int af_packet_enable_disable_qdisc_bypass (u32 sw_if_index, u8 enable_disable);
int af_packet_dump_ifs (af_packet_if_detail_t ** out_af_packet_ifs);
+u32 af_packet_get_if_capabilities (u8 *host_if_name);
format_function_t format_af_packet_device_name;
}
#endif /* CLIB_MARCH_VARIANT */
+static u8 *
+format_af_packet_offload_flag (u8 *s, va_list *args)
+{
+ af_packet_offload_flag_t af_oflags =
+ va_arg (*args, af_packet_offload_flag_t);
+ u32 indent = va_arg (*args, u32);
+
+#define _(o, n, str) \
+ if (af_oflags & AF_PACKET_OFFLOAD_FLAG_##o) \
+ s = format (s, "\n%U%s", format_white_space, indent + 3, str);
+ foreach_af_packet_offload_flag
+#undef _
+ return s;
+}
+
static u8 *
format_af_packet_device (u8 * s, va_list * args)
{
s = format (s, "\n%Ucksum-gso-enabled", format_white_space, indent + 2);
if (apif->is_fanout_enabled)
s = format (s, "\n%Ufanout-enabled", format_white_space, indent + 2);
+ s = format (s, "\n%UHost Interface Offload:", format_white_space, indent);
+ s = format (s, "\n%Ucreation time:%U", format_white_space, indent + 2,
+ format_af_packet_offload_flag, apif->host_interface_oflags,
+ indent);
+ s = format (s, "\n%Unow:%U", format_white_space, indent + 2,
+ format_af_packet_offload_flag,
+ af_packet_get_if_capabilities (apif->host_if_name), indent);
vec_foreach (rx_queue, apif->rx_queues)
{