96
97
static int do_grxclsrule(int fd, struct ifreq *ifr);
97
98
static int do_flash(int fd, struct ifreq *ifr);
98
99
static int do_permaddr(int fd, struct ifreq *ifr);
100
static int do_getfwdump(int fd, struct ifreq *ifr);
101
static int do_setfwdump(int fd, struct ifreq *ifr);
100
103
static int send_ioctl(int fd, struct ifreq *ifr);
255
260
" [ rule %d ]\n"},
256
261
{ "-P", "--show-permaddr", MODE_PERMADDR,
257
262
"Show permanent hardware address" },
263
{ "-w", "--get-dump", MODE_GET_DUMP,
264
"Get dump flag, data",
265
" [ data FILENAME ]\n" },
266
{ "-W", "--set-dump", MODE_SET_DUMP,
267
"Set dump flag of the device",
258
269
{ "-h", "--help", MODE_HELP, "Show this help" },
259
270
{ NULL, "--version", MODE_VERSION, "Show version number" },
365
376
static char *gregs_dump_file = NULL;
366
377
static int geeprom_changed = 0;
367
378
static int geeprom_dump_raw = 0;
368
static s32 geeprom_offset = 0;
369
static s32 geeprom_length = -1;
379
static u32 geeprom_offset = 0;
380
static u32 geeprom_length = -1;
370
381
static int seeprom_changed = 0;
371
static s32 seeprom_magic = 0;
372
static s32 seeprom_length = -1;
373
static s32 seeprom_offset = 0;
374
static s32 seeprom_value = EOF;
382
static u32 seeprom_magic = 0;
383
static u32 seeprom_length = -1;
384
static u32 seeprom_offset = 0;
385
static u8 seeprom_value = 0;
386
static int seeprom_value_seen = 0;
375
387
static int rx_fhash_get = 0;
376
388
static int rx_fhash_set = 0;
377
389
static u32 rx_fhash_val = 0;
435
450
static struct cmdline_info cmdline_geeprom[] = {
436
{ "offset", CMDL_S32, &geeprom_offset, NULL },
437
{ "length", CMDL_S32, &geeprom_length, NULL },
451
{ "offset", CMDL_U32, &geeprom_offset, NULL },
452
{ "length", CMDL_U32, &geeprom_length, NULL },
438
453
{ "raw", CMDL_BOOL, &geeprom_dump_raw, NULL },
441
456
static struct cmdline_info cmdline_seeprom[] = {
442
{ "magic", CMDL_S32, &seeprom_magic, NULL },
443
{ "offset", CMDL_S32, &seeprom_offset, NULL },
444
{ "length", CMDL_S32, &seeprom_length, NULL },
445
{ "value", CMDL_S32, &seeprom_value, NULL },
457
{ "magic", CMDL_U32, &seeprom_magic, NULL },
458
{ "offset", CMDL_U32, &seeprom_offset, NULL },
459
{ "length", CMDL_U32, &seeprom_length, NULL },
460
{ "value", CMDL_U8, &seeprom_value, NULL,
461
0, &seeprom_value_seen },
448
464
static struct cmdline_info cmdline_offload[] = {
1150
1192
fprintf(stdout, "FIBRE ");
1151
1193
fprintf(stdout, "]\n");
1153
fprintf(stdout, " Supported link modes: ");
1155
if (mask & SUPPORTED_10baseT_Half) {
1156
did1++; fprintf(stdout, "10baseT/Half ");
1158
if (mask & SUPPORTED_10baseT_Full) {
1159
did1++; fprintf(stdout, "10baseT/Full ");
1161
if (did1 && (mask & (SUPPORTED_100baseT_Half|SUPPORTED_100baseT_Full))) {
1162
fprintf(stdout, "\n");
1163
fprintf(stdout, " ");
1165
if (mask & SUPPORTED_100baseT_Half) {
1166
did1++; fprintf(stdout, "100baseT/Half ");
1168
if (mask & SUPPORTED_100baseT_Full) {
1169
did1++; fprintf(stdout, "100baseT/Full ");
1171
if (did1 && (mask & (SUPPORTED_1000baseT_Half|SUPPORTED_1000baseT_Full))) {
1172
fprintf(stdout, "\n");
1173
fprintf(stdout, " ");
1175
if (mask & SUPPORTED_1000baseT_Half) {
1176
did1++; fprintf(stdout, "1000baseT/Half ");
1178
if (mask & SUPPORTED_1000baseT_Full) {
1179
did1++; fprintf(stdout, "1000baseT/Full ");
1181
if (did1 && (mask & SUPPORTED_2500baseX_Full)) {
1182
fprintf(stdout, "\n");
1183
fprintf(stdout, " ");
1185
if (mask & SUPPORTED_2500baseX_Full) {
1186
did1++; fprintf(stdout, "2500baseX/Full ");
1188
if (did1 && (mask & SUPPORTED_10000baseT_Full)) {
1189
fprintf(stdout, "\n");
1190
fprintf(stdout, " ");
1192
if (mask & SUPPORTED_10000baseT_Full) {
1193
did1++; fprintf(stdout, "10000baseT/Full ");
1195
fprintf(stdout, "\n");
1197
fprintf(stdout, " Supports auto-negotiation: ");
1198
if (mask & SUPPORTED_Autoneg)
1199
fprintf(stdout, "Yes\n");
1201
fprintf(stdout, "No\n");
1195
dump_link_caps("Supported", "Supports", mask);
1204
static void dump_advertised(struct ethtool_cmd *ep,
1205
const char *prefix, u_int32_t mask)
1198
/* Print link capability flags (supported, advertised or lp_advertised).
1199
* Assumes that the corresponding SUPPORTED and ADVERTISED flags are equal.
1202
dump_link_caps(const char *prefix, const char *an_prefix, u32 mask)
1207
int indent = strlen(prefix) + 14;
1210
fprintf(stdout, " %s link modes: ", prefix);
1207
/* Indent just like the separate functions used to */
1208
indent = strlen(prefix) + 14;
1212
fprintf(stdout, " %s link modes:%*s", prefix,
1213
indent - (int)strlen(prefix) - 12, "");
1212
1215
if (mask & ADVERTISED_10baseT_Half) {
1213
1216
did1++; fprintf(stdout, "10baseT/Half ");
1249
1252
if (mask & ADVERTISED_10000baseT_Full) {
1250
1253
did1++; fprintf(stdout, "10000baseT/Full ");
1255
if (did1 && (mask & ADVERTISED_20000baseMLD2_Full)) {
1256
fprintf(stdout, "\n");
1257
fprintf(stdout, " %*s", indent, "");
1259
if (mask & ADVERTISED_20000baseMLD2_Full) {
1260
did1++; fprintf(stdout, "20000baseMLD2/Full ");
1262
if (did1 && (mask & ADVERTISED_20000baseKR2_Full)) {
1263
fprintf(stdout, "\n");
1264
fprintf(stdout, " %*s", indent, "");
1266
if (mask & ADVERTISED_20000baseKR2_Full) {
1267
did1++; fprintf(stdout, "20000baseKR2/Full ");
1253
1270
fprintf(stdout, "Not reported");
1254
1271
fprintf(stdout, "\n");
1280
1297
dump_supported(ep);
1281
dump_advertised(ep, "Advertised", ep->advertising);
1298
dump_link_caps("Advertised", "Advertised", ep->advertising);
1282
1299
if (ep->lp_advertising)
1283
dump_advertised(ep, "Link partner advertised",
1284
ep->lp_advertising);
1300
dump_link_caps("Link partner advertised",
1301
"Link partner advertised", ep->lp_advertising);
1286
1303
fprintf(stdout, " Speed: ");
1287
1304
speed = ethtool_cmd_speed(ep);
1936
1953
return do_flash(fd, &ifr);
1937
1954
} else if (mode == MODE_PERMADDR) {
1938
1955
return do_permaddr(fd, &ifr);
1956
} else if (mode == MODE_GET_DUMP) {
1957
return do_getfwdump(fd, &ifr);
1958
} else if (mode == MODE_SET_DUMP) {
1959
return do_setfwdump(fd, &ifr);
2475
2496
ADVERTISED_1000baseT_Half |
2476
2497
ADVERTISED_1000baseT_Full |
2477
2498
ADVERTISED_2500baseX_Full |
2478
ADVERTISED_10000baseT_Full);
2499
ADVERTISED_10000baseT_Full |
2500
ADVERTISED_20000baseMLD2_Full |
2501
ADVERTISED_20000baseKR2_Full);
2479
2502
} else if (advertising_wanted > 0) {
2480
2503
ecmd.advertising = advertising_wanted;
3242
3265
return err ? 1 : 0;
3268
static int do_writefwdump(struct ethtool_dump *dump)
3274
f = fopen(dump_file, "wb+");
3277
fprintf(stderr, "Can't open file %s: %s\n",
3278
dump_file, strerror(errno));
3281
bytes = fwrite(dump->data, 1, dump->len, f);
3282
if (bytes != dump->len) {
3283
fprintf(stderr, "Can not write all of dump data\n");
3287
fprintf(stderr, "Can't close file %s: %s\n",
3288
dump_file, strerror(errno));
3294
static int do_getfwdump(int fd, struct ifreq *ifr)
3297
struct ethtool_dump edata;
3298
struct ethtool_dump *data;
3300
edata.cmd = ETHTOOL_GET_DUMP_FLAG;
3302
ifr->ifr_data = (caddr_t) &edata;
3303
err = send_ioctl(fd, ifr);
3305
perror("Can not get dump level\n");
3308
if (dump_flag != ETHTOOL_GET_DUMP_DATA) {
3309
fprintf(stdout, "flag: %u, version: %u, length: %u\n",
3310
edata.flag, edata.version, edata.len);
3313
data = calloc(1, offsetof(struct ethtool_dump, data) + edata.len);
3315
perror("Can not allocate enough memory\n");
3318
data->cmd = ETHTOOL_GET_DUMP_DATA;
3319
data->len = edata.len;
3320
ifr->ifr_data = (caddr_t) data;
3321
err = send_ioctl(fd, ifr);
3323
perror("Can not get dump data\n");
3327
err = do_writefwdump(data);
3333
static int do_setfwdump(int fd, struct ifreq *ifr)
3336
struct ethtool_dump dump;
3338
dump.cmd = ETHTOOL_SET_DUMP;
3339
dump.flag = dump_flag;
3340
ifr->ifr_data = (caddr_t)&dump;
3341
err = send_ioctl(fd, ifr);
3343
perror("Can not set dump level\n");
3245
3349
static int send_ioctl(int fd, struct ifreq *ifr)
3247
3351
return ioctl(fd, SIOCETHTOOL, ifr);