@@ -173,3 +173,46 @@ void dump_mdix(u8 mdix, u8 mdix_ctrl)
fprintf(stdout, "\n");
}
}
+
+void print_indir_table(struct cmd_context *ctx, u64 ring_count,
+ u32 indir_size, u32 *indir)
+{
+ u32 i;
+
+ printf("RX flow hash indirection table for %s with %llu RX ring(s):\n",
+ ctx->devname, ring_count);
+
+ if (!indir_size)
+ printf("Operation not supported\n");
+
+ for (i = 0; i < indir_size; i++) {
+ if (i % 8 == 0)
+ printf("%5u: ", i);
+ printf(" %5u", indir[i]);
+ if (i % 8 == 7 || i == indir_size - 1)
+ fputc('\n', stdout);
+ }
+}
+
+void print_rss_info(struct cmd_context *ctx, u64 ring_count,
+ struct ethtool_rxfh *rss)
+{
+ u32 i, indir_bytes;
+ char *hkey;
+
+ print_indir_table(ctx, ring_count, rss->indir_size, rss->rss_config);
+
+ indir_bytes = rss->indir_size * sizeof(rss->rss_config[0]);
+ hkey = ((char *)rss->rss_config + indir_bytes);
+
+ printf("RSS hash key:\n");
+ if (!rss->key_size)
+ printf("Operation not supported\n");
+
+ for (i = 0; i < rss->key_size; i++) {
+ if (i == (rss->key_size - 1))
+ printf("%02x\n", (u8)hkey[i]);
+ else
+ printf("%02x:", (u8)hkey[i]);
+ }
+}
@@ -8,6 +8,8 @@
#define ETHTOOL_COMMON_H__
#include "internal.h"
+#include <stddef.h>
+#include <errno.h>
#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
@@ -41,5 +43,10 @@ extern const struct off_flag_def off_flag_def[OFF_FLAG_DEF_SIZE];
void print_flags(const struct flag_info *info, unsigned int n_info, u32 value);
int dump_wol(struct ethtool_wolinfo *wol);
void dump_mdix(u8 mdix, u8 mdix_ctrl);
+void print_indir_table(struct cmd_context *ctx, u64 ring_count,
+ u32 indir_size, u32 *indir);
+
+void print_rss_info(struct cmd_context *ctx, u64 ring_count,
+ struct ethtool_rxfh *rss);
#endif /* ETHTOOL_COMMON_H__ */
@@ -3880,27 +3880,6 @@ static int do_grxclass(struct cmd_context *ctx)
return err ? 1 : 0;
}
-static void print_indir_table(struct cmd_context *ctx,
- struct ethtool_rxnfc *ring_count,
- u32 indir_size, u32 *indir)
-{
- u32 i;
-
- printf("RX flow hash indirection table for %s with %llu RX ring(s):\n",
- ctx->devname, ring_count->data);
-
- if (!indir_size)
- printf("Operation not supported\n");
-
- for (i = 0; i < indir_size; i++) {
- if (i % 8 == 0)
- printf("%5u: ", i);
- printf(" %5u", indir[i]);
- if (i % 8 == 7 || i == indir_size - 1)
- fputc('\n', stdout);
- }
-}
-
static int do_grxfhindir(struct cmd_context *ctx,
struct ethtool_rxnfc *ring_count)
{
@@ -3932,7 +3911,8 @@ static int do_grxfhindir(struct cmd_context *ctx,
return 1;
}
- print_indir_table(ctx, ring_count, indir->size, indir->ring_index);
+ print_indir_table(ctx, ring_count->data, indir->size,
+ indir->ring_index);
free(indir);
return 0;
@@ -3945,9 +3925,7 @@ static int do_grxfh(struct cmd_context *ctx)
struct ethtool_rxnfc ring_count;
struct ethtool_rxfh *rss;
u32 rss_context = 0;
- u32 i, indir_bytes;
- unsigned int arg_num = 0;
- char *hkey;
+ unsigned int arg_num = 0, i;
int err;
while (arg_num < ctx->argc) {
@@ -3997,21 +3975,7 @@ static int do_grxfh(struct cmd_context *ctx)
return 1;
}
- print_indir_table(ctx, &ring_count, rss->indir_size, rss->rss_config);
-
- indir_bytes = rss->indir_size * sizeof(rss->rss_config[0]);
- hkey = ((char *)rss->rss_config + indir_bytes);
-
- printf("RSS hash key:\n");
- if (!rss->key_size)
- printf("Operation not supported\n");
-
- for (i = 0; i < rss->key_size; i++) {
- if (i == (rss->key_size - 1))
- printf("%02x\n", (u8) hkey[i]);
- else
- printf("%02x:", (u8) hkey[i]);
- }
+ print_rss_info(ctx, ring_count.data, rss);
printf("RSS hash function:\n");
if (!rss->hfunc) {
Move functions that print rss indirection table and hash key into common file for use by both netlink and ioctl interface. Changed function argument to be ring count instead of structure. Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com> --- common.c | 43 +++++++++++++++++++++++++++++++++++++++++++ common.h | 7 +++++++ ethtool.c | 44 ++++---------------------------------------- 3 files changed, 54 insertions(+), 40 deletions(-)