diff options
Diffstat (limited to 'net/core/ethtool.c')
| -rw-r--r-- | net/core/ethtool.c | 434 |
1 files changed, 420 insertions, 14 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 236a9988ea91..9d55c57f318a 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -17,6 +17,8 @@ | |||
| 17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
| 18 | #include <linux/ethtool.h> | 18 | #include <linux/ethtool.h> |
| 19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
| 20 | #include <linux/bitops.h> | ||
| 21 | #include <linux/slab.h> | ||
| 20 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
| 21 | 23 | ||
| 22 | /* | 24 | /* |
| @@ -120,7 +122,7 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data) | |||
| 120 | * NETIF_F_xxx values in include/linux/netdevice.h | 122 | * NETIF_F_xxx values in include/linux/netdevice.h |
| 121 | */ | 123 | */ |
| 122 | static const u32 flags_dup_features = | 124 | static const u32 flags_dup_features = |
| 123 | ETH_FLAG_LRO; | 125 | (ETH_FLAG_LRO | ETH_FLAG_NTUPLE); |
| 124 | 126 | ||
| 125 | u32 ethtool_op_get_flags(struct net_device *dev) | 127 | u32 ethtool_op_get_flags(struct net_device *dev) |
| 126 | { | 128 | { |
| @@ -134,19 +136,44 @@ u32 ethtool_op_get_flags(struct net_device *dev) | |||
| 134 | 136 | ||
| 135 | int ethtool_op_set_flags(struct net_device *dev, u32 data) | 137 | int ethtool_op_set_flags(struct net_device *dev, u32 data) |
| 136 | { | 138 | { |
| 139 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
| 140 | unsigned long features = dev->features; | ||
| 141 | |||
| 137 | if (data & ETH_FLAG_LRO) | 142 | if (data & ETH_FLAG_LRO) |
| 138 | dev->features |= NETIF_F_LRO; | 143 | features |= NETIF_F_LRO; |
| 139 | else | 144 | else |
| 140 | dev->features &= ~NETIF_F_LRO; | 145 | features &= ~NETIF_F_LRO; |
| 146 | |||
| 147 | if (data & ETH_FLAG_NTUPLE) { | ||
| 148 | if (!ops->set_rx_ntuple) | ||
| 149 | return -EOPNOTSUPP; | ||
| 150 | features |= NETIF_F_NTUPLE; | ||
| 151 | } else { | ||
| 152 | /* safe to clear regardless */ | ||
| 153 | features &= ~NETIF_F_NTUPLE; | ||
| 154 | } | ||
| 141 | 155 | ||
| 156 | dev->features = features; | ||
| 142 | return 0; | 157 | return 0; |
| 143 | } | 158 | } |
| 144 | 159 | ||
| 160 | void ethtool_ntuple_flush(struct net_device *dev) | ||
| 161 | { | ||
| 162 | struct ethtool_rx_ntuple_flow_spec_container *fsc, *f; | ||
| 163 | |||
| 164 | list_for_each_entry_safe(fsc, f, &dev->ethtool_ntuple_list.list, list) { | ||
| 165 | list_del(&fsc->list); | ||
| 166 | kfree(fsc); | ||
| 167 | } | ||
| 168 | dev->ethtool_ntuple_list.count = 0; | ||
| 169 | } | ||
| 170 | EXPORT_SYMBOL(ethtool_ntuple_flush); | ||
| 171 | |||
| 145 | /* Handlers for each ethtool command */ | 172 | /* Handlers for each ethtool command */ |
| 146 | 173 | ||
| 147 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) | 174 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) |
| 148 | { | 175 | { |
| 149 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | 176 | struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; |
| 150 | int err; | 177 | int err; |
| 151 | 178 | ||
| 152 | if (!dev->ethtool_ops->get_settings) | 179 | if (!dev->ethtool_ops->get_settings) |
| @@ -174,7 +201,7 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr) | |||
| 174 | return dev->ethtool_ops->set_settings(dev, &cmd); | 201 | return dev->ethtool_ops->set_settings(dev, &cmd); |
| 175 | } | 202 | } |
| 176 | 203 | ||
| 177 | static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) | 204 | static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) |
| 178 | { | 205 | { |
| 179 | struct ethtool_drvinfo info; | 206 | struct ethtool_drvinfo info; |
| 180 | const struct ethtool_ops *ops = dev->ethtool_ops; | 207 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| @@ -186,6 +213,10 @@ static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) | |||
| 186 | info.cmd = ETHTOOL_GDRVINFO; | 213 | info.cmd = ETHTOOL_GDRVINFO; |
| 187 | ops->get_drvinfo(dev, &info); | 214 | ops->get_drvinfo(dev, &info); |
| 188 | 215 | ||
| 216 | /* | ||
| 217 | * this method of obtaining string set info is deprecated; | ||
| 218 | * Use ETHTOOL_GSSET_INFO instead. | ||
| 219 | */ | ||
| 189 | if (ops->get_sset_count) { | 220 | if (ops->get_sset_count) { |
| 190 | int rc; | 221 | int rc; |
| 191 | 222 | ||
| @@ -209,7 +240,67 @@ static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) | |||
| 209 | return 0; | 240 | return 0; |
| 210 | } | 241 | } |
| 211 | 242 | ||
| 212 | static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr) | 243 | static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev, |
| 244 | void __user *useraddr) | ||
| 245 | { | ||
| 246 | struct ethtool_sset_info info; | ||
| 247 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
| 248 | u64 sset_mask; | ||
| 249 | int i, idx = 0, n_bits = 0, ret, rc; | ||
| 250 | u32 *info_buf = NULL; | ||
| 251 | |||
| 252 | if (!ops->get_sset_count) | ||
| 253 | return -EOPNOTSUPP; | ||
| 254 | |||
| 255 | if (copy_from_user(&info, useraddr, sizeof(info))) | ||
| 256 | return -EFAULT; | ||
| 257 | |||
| 258 | /* store copy of mask, because we zero struct later on */ | ||
| 259 | sset_mask = info.sset_mask; | ||
| 260 | if (!sset_mask) | ||
| 261 | return 0; | ||
| 262 | |||
| 263 | /* calculate size of return buffer */ | ||
| 264 | n_bits = hweight64(sset_mask); | ||
| 265 | |||
| 266 | memset(&info, 0, sizeof(info)); | ||
| 267 | info.cmd = ETHTOOL_GSSET_INFO; | ||
| 268 | |||
| 269 | info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER); | ||
| 270 | if (!info_buf) | ||
| 271 | return -ENOMEM; | ||
| 272 | |||
| 273 | /* | ||
| 274 | * fill return buffer based on input bitmask and successful | ||
| 275 | * get_sset_count return | ||
| 276 | */ | ||
| 277 | for (i = 0; i < 64; i++) { | ||
| 278 | if (!(sset_mask & (1ULL << i))) | ||
| 279 | continue; | ||
| 280 | |||
| 281 | rc = ops->get_sset_count(dev, i); | ||
| 282 | if (rc >= 0) { | ||
| 283 | info.sset_mask |= (1ULL << i); | ||
| 284 | info_buf[idx++] = rc; | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | ret = -EFAULT; | ||
| 289 | if (copy_to_user(useraddr, &info, sizeof(info))) | ||
| 290 | goto out; | ||
| 291 | |||
| 292 | useraddr += offsetof(struct ethtool_sset_info, data); | ||
| 293 | if (copy_to_user(useraddr, info_buf, idx * sizeof(u32))) | ||
| 294 | goto out; | ||
| 295 | |||
| 296 | ret = 0; | ||
| 297 | |||
| 298 | out: | ||
| 299 | kfree(info_buf); | ||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | |||
| 303 | static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr) | ||
| 213 | { | 304 | { |
| 214 | struct ethtool_rxnfc cmd; | 305 | struct ethtool_rxnfc cmd; |
| 215 | 306 | ||
| @@ -222,7 +313,7 @@ static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr) | |||
| 222 | return dev->ethtool_ops->set_rxnfc(dev, &cmd); | 313 | return dev->ethtool_ops->set_rxnfc(dev, &cmd); |
| 223 | } | 314 | } |
| 224 | 315 | ||
| 225 | static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr) | 316 | static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr) |
| 226 | { | 317 | { |
| 227 | struct ethtool_rxnfc info; | 318 | struct ethtool_rxnfc info; |
| 228 | const struct ethtool_ops *ops = dev->ethtool_ops; | 319 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| @@ -266,6 +357,312 @@ err_out: | |||
| 266 | return ret; | 357 | return ret; |
| 267 | } | 358 | } |
| 268 | 359 | ||
| 360 | static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list, | ||
| 361 | struct ethtool_rx_ntuple_flow_spec *spec, | ||
| 362 | struct ethtool_rx_ntuple_flow_spec_container *fsc) | ||
| 363 | { | ||
| 364 | |||
| 365 | /* don't add filters forever */ | ||
| 366 | if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) { | ||
| 367 | /* free the container */ | ||
| 368 | kfree(fsc); | ||
| 369 | return; | ||
| 370 | } | ||
| 371 | |||
| 372 | /* Copy the whole filter over */ | ||
| 373 | fsc->fs.flow_type = spec->flow_type; | ||
| 374 | memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u)); | ||
| 375 | memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u)); | ||
| 376 | |||
| 377 | fsc->fs.vlan_tag = spec->vlan_tag; | ||
| 378 | fsc->fs.vlan_tag_mask = spec->vlan_tag_mask; | ||
| 379 | fsc->fs.data = spec->data; | ||
| 380 | fsc->fs.data_mask = spec->data_mask; | ||
| 381 | fsc->fs.action = spec->action; | ||
| 382 | |||
| 383 | /* add to the list */ | ||
| 384 | list_add_tail_rcu(&fsc->list, &list->list); | ||
| 385 | list->count++; | ||
| 386 | } | ||
| 387 | |||
| 388 | static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr) | ||
| 389 | { | ||
| 390 | struct ethtool_rx_ntuple cmd; | ||
| 391 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
| 392 | struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL; | ||
| 393 | int ret; | ||
| 394 | |||
| 395 | if (!(dev->features & NETIF_F_NTUPLE)) | ||
| 396 | return -EINVAL; | ||
| 397 | |||
| 398 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | ||
| 399 | return -EFAULT; | ||
| 400 | |||
| 401 | /* | ||
| 402 | * Cache filter in dev struct for GET operation only if | ||
| 403 | * the underlying driver doesn't have its own GET operation, and | ||
| 404 | * only if the filter was added successfully. First make sure we | ||
| 405 | * can allocate the filter, then continue if successful. | ||
| 406 | */ | ||
| 407 | if (!ops->get_rx_ntuple) { | ||
| 408 | fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC); | ||
| 409 | if (!fsc) | ||
| 410 | return -ENOMEM; | ||
| 411 | } | ||
| 412 | |||
| 413 | ret = ops->set_rx_ntuple(dev, &cmd); | ||
| 414 | if (ret) { | ||
| 415 | kfree(fsc); | ||
| 416 | return ret; | ||
| 417 | } | ||
| 418 | |||
| 419 | if (!ops->get_rx_ntuple) | ||
| 420 | __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc); | ||
| 421 | |||
| 422 | return ret; | ||
| 423 | } | ||
| 424 | |||
| 425 | static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr) | ||
| 426 | { | ||
| 427 | struct ethtool_gstrings gstrings; | ||
| 428 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
| 429 | struct ethtool_rx_ntuple_flow_spec_container *fsc; | ||
| 430 | u8 *data; | ||
| 431 | char *p; | ||
| 432 | int ret, i, num_strings = 0; | ||
| 433 | |||
| 434 | if (!ops->get_sset_count) | ||
| 435 | return -EOPNOTSUPP; | ||
| 436 | |||
| 437 | if (copy_from_user(&gstrings, useraddr, sizeof(gstrings))) | ||
| 438 | return -EFAULT; | ||
| 439 | |||
| 440 | ret = ops->get_sset_count(dev, gstrings.string_set); | ||
| 441 | if (ret < 0) | ||
| 442 | return ret; | ||
| 443 | |||
| 444 | gstrings.len = ret; | ||
| 445 | |||
| 446 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); | ||
| 447 | if (!data) | ||
| 448 | return -ENOMEM; | ||
| 449 | |||
| 450 | if (ops->get_rx_ntuple) { | ||
| 451 | /* driver-specific filter grab */ | ||
| 452 | ret = ops->get_rx_ntuple(dev, gstrings.string_set, data); | ||
| 453 | goto copy; | ||
| 454 | } | ||
| 455 | |||
| 456 | /* default ethtool filter grab */ | ||
| 457 | i = 0; | ||
| 458 | p = (char *)data; | ||
| 459 | list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) { | ||
| 460 | sprintf(p, "Filter %d:\n", i); | ||
| 461 | p += ETH_GSTRING_LEN; | ||
| 462 | num_strings++; | ||
| 463 | |||
| 464 | switch (fsc->fs.flow_type) { | ||
| 465 | case TCP_V4_FLOW: | ||
| 466 | sprintf(p, "\tFlow Type: TCP\n"); | ||
| 467 | p += ETH_GSTRING_LEN; | ||
| 468 | num_strings++; | ||
| 469 | break; | ||
| 470 | case UDP_V4_FLOW: | ||
| 471 | sprintf(p, "\tFlow Type: UDP\n"); | ||
| 472 | p += ETH_GSTRING_LEN; | ||
| 473 | num_strings++; | ||
| 474 | break; | ||
| 475 | case SCTP_V4_FLOW: | ||
| 476 | sprintf(p, "\tFlow Type: SCTP\n"); | ||
| 477 | p += ETH_GSTRING_LEN; | ||
| 478 | num_strings++; | ||
| 479 | break; | ||
| 480 | case AH_ESP_V4_FLOW: | ||
| 481 | sprintf(p, "\tFlow Type: AH ESP\n"); | ||
| 482 | p += ETH_GSTRING_LEN; | ||
| 483 | num_strings++; | ||
| 484 | break; | ||
| 485 | case ESP_V4_FLOW: | ||
| 486 | sprintf(p, "\tFlow Type: ESP\n"); | ||
| 487 | p += ETH_GSTRING_LEN; | ||
| 488 | num_strings++; | ||
| 489 | break; | ||
| 490 | case IP_USER_FLOW: | ||
| 491 | sprintf(p, "\tFlow Type: Raw IP\n"); | ||
| 492 | p += ETH_GSTRING_LEN; | ||
| 493 | num_strings++; | ||
| 494 | break; | ||
| 495 | case IPV4_FLOW: | ||
| 496 | sprintf(p, "\tFlow Type: IPv4\n"); | ||
| 497 | p += ETH_GSTRING_LEN; | ||
| 498 | num_strings++; | ||
| 499 | break; | ||
| 500 | default: | ||
| 501 | sprintf(p, "\tFlow Type: Unknown\n"); | ||
| 502 | p += ETH_GSTRING_LEN; | ||
| 503 | num_strings++; | ||
| 504 | goto unknown_filter; | ||
| 505 | }; | ||
| 506 | |||
| 507 | /* now the rest of the filters */ | ||
| 508 | switch (fsc->fs.flow_type) { | ||
| 509 | case TCP_V4_FLOW: | ||
| 510 | case UDP_V4_FLOW: | ||
| 511 | case SCTP_V4_FLOW: | ||
| 512 | sprintf(p, "\tSrc IP addr: 0x%x\n", | ||
| 513 | fsc->fs.h_u.tcp_ip4_spec.ip4src); | ||
| 514 | p += ETH_GSTRING_LEN; | ||
| 515 | num_strings++; | ||
| 516 | sprintf(p, "\tSrc IP mask: 0x%x\n", | ||
| 517 | fsc->fs.m_u.tcp_ip4_spec.ip4src); | ||
| 518 | p += ETH_GSTRING_LEN; | ||
| 519 | num_strings++; | ||
| 520 | sprintf(p, "\tDest IP addr: 0x%x\n", | ||
| 521 | fsc->fs.h_u.tcp_ip4_spec.ip4dst); | ||
| 522 | p += ETH_GSTRING_LEN; | ||
| 523 | num_strings++; | ||
| 524 | sprintf(p, "\tDest IP mask: 0x%x\n", | ||
| 525 | fsc->fs.m_u.tcp_ip4_spec.ip4dst); | ||
| 526 | p += ETH_GSTRING_LEN; | ||
| 527 | num_strings++; | ||
| 528 | sprintf(p, "\tSrc Port: %d, mask: 0x%x\n", | ||
| 529 | fsc->fs.h_u.tcp_ip4_spec.psrc, | ||
| 530 | fsc->fs.m_u.tcp_ip4_spec.psrc); | ||
| 531 | p += ETH_GSTRING_LEN; | ||
| 532 | num_strings++; | ||
| 533 | sprintf(p, "\tDest Port: %d, mask: 0x%x\n", | ||
| 534 | fsc->fs.h_u.tcp_ip4_spec.pdst, | ||
| 535 | fsc->fs.m_u.tcp_ip4_spec.pdst); | ||
| 536 | p += ETH_GSTRING_LEN; | ||
| 537 | num_strings++; | ||
| 538 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | ||
| 539 | fsc->fs.h_u.tcp_ip4_spec.tos, | ||
| 540 | fsc->fs.m_u.tcp_ip4_spec.tos); | ||
| 541 | p += ETH_GSTRING_LEN; | ||
| 542 | num_strings++; | ||
| 543 | break; | ||
| 544 | case AH_ESP_V4_FLOW: | ||
| 545 | case ESP_V4_FLOW: | ||
| 546 | sprintf(p, "\tSrc IP addr: 0x%x\n", | ||
| 547 | fsc->fs.h_u.ah_ip4_spec.ip4src); | ||
| 548 | p += ETH_GSTRING_LEN; | ||
| 549 | num_strings++; | ||
| 550 | sprintf(p, "\tSrc IP mask: 0x%x\n", | ||
| 551 | fsc->fs.m_u.ah_ip4_spec.ip4src); | ||
| 552 | p += ETH_GSTRING_LEN; | ||
| 553 | num_strings++; | ||
| 554 | sprintf(p, "\tDest IP addr: 0x%x\n", | ||
| 555 | fsc->fs.h_u.ah_ip4_spec.ip4dst); | ||
| 556 | p += ETH_GSTRING_LEN; | ||
| 557 | num_strings++; | ||
| 558 | sprintf(p, "\tDest IP mask: 0x%x\n", | ||
| 559 | fsc->fs.m_u.ah_ip4_spec.ip4dst); | ||
| 560 | p += ETH_GSTRING_LEN; | ||
| 561 | num_strings++; | ||
| 562 | sprintf(p, "\tSPI: %d, mask: 0x%x\n", | ||
| 563 | fsc->fs.h_u.ah_ip4_spec.spi, | ||
| 564 | fsc->fs.m_u.ah_ip4_spec.spi); | ||
| 565 | p += ETH_GSTRING_LEN; | ||
| 566 | num_strings++; | ||
| 567 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | ||
| 568 | fsc->fs.h_u.ah_ip4_spec.tos, | ||
| 569 | fsc->fs.m_u.ah_ip4_spec.tos); | ||
| 570 | p += ETH_GSTRING_LEN; | ||
| 571 | num_strings++; | ||
| 572 | break; | ||
| 573 | case IP_USER_FLOW: | ||
| 574 | sprintf(p, "\tSrc IP addr: 0x%x\n", | ||
| 575 | fsc->fs.h_u.raw_ip4_spec.ip4src); | ||
| 576 | p += ETH_GSTRING_LEN; | ||
| 577 | num_strings++; | ||
| 578 | sprintf(p, "\tSrc IP mask: 0x%x\n", | ||
| 579 | fsc->fs.m_u.raw_ip4_spec.ip4src); | ||
| 580 | p += ETH_GSTRING_LEN; | ||
| 581 | num_strings++; | ||
| 582 | sprintf(p, "\tDest IP addr: 0x%x\n", | ||
| 583 | fsc->fs.h_u.raw_ip4_spec.ip4dst); | ||
| 584 | p += ETH_GSTRING_LEN; | ||
| 585 | num_strings++; | ||
| 586 | sprintf(p, "\tDest IP mask: 0x%x\n", | ||
| 587 | fsc->fs.m_u.raw_ip4_spec.ip4dst); | ||
| 588 | p += ETH_GSTRING_LEN; | ||
| 589 | num_strings++; | ||
| 590 | break; | ||
| 591 | case IPV4_FLOW: | ||
| 592 | sprintf(p, "\tSrc IP addr: 0x%x\n", | ||
| 593 | fsc->fs.h_u.usr_ip4_spec.ip4src); | ||
| 594 | p += ETH_GSTRING_LEN; | ||
| 595 | num_strings++; | ||
| 596 | sprintf(p, "\tSrc IP mask: 0x%x\n", | ||
| 597 | fsc->fs.m_u.usr_ip4_spec.ip4src); | ||
| 598 | p += ETH_GSTRING_LEN; | ||
| 599 | num_strings++; | ||
| 600 | sprintf(p, "\tDest IP addr: 0x%x\n", | ||
| 601 | fsc->fs.h_u.usr_ip4_spec.ip4dst); | ||
| 602 | p += ETH_GSTRING_LEN; | ||
| 603 | num_strings++; | ||
| 604 | sprintf(p, "\tDest IP mask: 0x%x\n", | ||
| 605 | fsc->fs.m_u.usr_ip4_spec.ip4dst); | ||
| 606 | p += ETH_GSTRING_LEN; | ||
| 607 | num_strings++; | ||
| 608 | sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n", | ||
| 609 | fsc->fs.h_u.usr_ip4_spec.l4_4_bytes, | ||
| 610 | fsc->fs.m_u.usr_ip4_spec.l4_4_bytes); | ||
| 611 | p += ETH_GSTRING_LEN; | ||
| 612 | num_strings++; | ||
| 613 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | ||
| 614 | fsc->fs.h_u.usr_ip4_spec.tos, | ||
| 615 | fsc->fs.m_u.usr_ip4_spec.tos); | ||
| 616 | p += ETH_GSTRING_LEN; | ||
| 617 | num_strings++; | ||
| 618 | sprintf(p, "\tIP Version: %d, mask: 0x%x\n", | ||
| 619 | fsc->fs.h_u.usr_ip4_spec.ip_ver, | ||
| 620 | fsc->fs.m_u.usr_ip4_spec.ip_ver); | ||
| 621 | p += ETH_GSTRING_LEN; | ||
| 622 | num_strings++; | ||
| 623 | sprintf(p, "\tProtocol: %d, mask: 0x%x\n", | ||
| 624 | fsc->fs.h_u.usr_ip4_spec.proto, | ||
| 625 | fsc->fs.m_u.usr_ip4_spec.proto); | ||
| 626 | p += ETH_GSTRING_LEN; | ||
| 627 | num_strings++; | ||
| 628 | break; | ||
| 629 | }; | ||
| 630 | sprintf(p, "\tVLAN: %d, mask: 0x%x\n", | ||
| 631 | fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask); | ||
| 632 | p += ETH_GSTRING_LEN; | ||
| 633 | num_strings++; | ||
| 634 | sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data); | ||
| 635 | p += ETH_GSTRING_LEN; | ||
| 636 | num_strings++; | ||
| 637 | sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask); | ||
| 638 | p += ETH_GSTRING_LEN; | ||
| 639 | num_strings++; | ||
| 640 | if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP) | ||
| 641 | sprintf(p, "\tAction: Drop\n"); | ||
| 642 | else | ||
| 643 | sprintf(p, "\tAction: Direct to queue %d\n", | ||
| 644 | fsc->fs.action); | ||
| 645 | p += ETH_GSTRING_LEN; | ||
| 646 | num_strings++; | ||
| 647 | unknown_filter: | ||
| 648 | i++; | ||
| 649 | } | ||
| 650 | copy: | ||
| 651 | /* indicate to userspace how many strings we actually have */ | ||
| 652 | gstrings.len = num_strings; | ||
| 653 | ret = -EFAULT; | ||
| 654 | if (copy_to_user(useraddr, &gstrings, sizeof(gstrings))) | ||
| 655 | goto out; | ||
| 656 | useraddr += sizeof(gstrings); | ||
| 657 | if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN)) | ||
| 658 | goto out; | ||
| 659 | ret = 0; | ||
| 660 | |||
| 661 | out: | ||
| 662 | kfree(data); | ||
| 663 | return ret; | ||
| 664 | } | ||
| 665 | |||
| 269 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) | 666 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) |
| 270 | { | 667 | { |
| 271 | struct ethtool_regs regs; | 668 | struct ethtool_regs regs; |
| @@ -324,7 +721,7 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr) | |||
| 324 | 721 | ||
| 325 | static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) | 722 | static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) |
| 326 | { | 723 | { |
| 327 | struct ethtool_wolinfo wol = { ETHTOOL_GWOL }; | 724 | struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; |
| 328 | 725 | ||
| 329 | if (!dev->ethtool_ops->get_wol) | 726 | if (!dev->ethtool_ops->get_wol) |
| 330 | return -EOPNOTSUPP; | 727 | return -EOPNOTSUPP; |
| @@ -456,9 +853,9 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) | |||
| 456 | return ret; | 853 | return ret; |
| 457 | } | 854 | } |
| 458 | 855 | ||
| 459 | static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr) | 856 | static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr) |
| 460 | { | 857 | { |
| 461 | struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE }; | 858 | struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE }; |
| 462 | 859 | ||
| 463 | if (!dev->ethtool_ops->get_coalesce) | 860 | if (!dev->ethtool_ops->get_coalesce) |
| 464 | return -EOPNOTSUPP; | 861 | return -EOPNOTSUPP; |
| @@ -470,7 +867,7 @@ static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr) | |||
| 470 | return 0; | 867 | return 0; |
| 471 | } | 868 | } |
| 472 | 869 | ||
| 473 | static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) | 870 | static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) |
| 474 | { | 871 | { |
| 475 | struct ethtool_coalesce coalesce; | 872 | struct ethtool_coalesce coalesce; |
| 476 | 873 | ||
| @@ -485,7 +882,7 @@ static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) | |||
| 485 | 882 | ||
| 486 | static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) | 883 | static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) |
| 487 | { | 884 | { |
| 488 | struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM }; | 885 | struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM }; |
| 489 | 886 | ||
| 490 | if (!dev->ethtool_ops->get_ringparam) | 887 | if (!dev->ethtool_ops->get_ringparam) |
| 491 | return -EOPNOTSUPP; | 888 | return -EOPNOTSUPP; |
| @@ -839,7 +1236,7 @@ static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr) | |||
| 839 | static int ethtool_get_value(struct net_device *dev, char __user *useraddr, | 1236 | static int ethtool_get_value(struct net_device *dev, char __user *useraddr, |
| 840 | u32 cmd, u32 (*actor)(struct net_device *)) | 1237 | u32 cmd, u32 (*actor)(struct net_device *)) |
| 841 | { | 1238 | { |
| 842 | struct ethtool_value edata = { cmd }; | 1239 | struct ethtool_value edata = { .cmd = cmd }; |
| 843 | 1240 | ||
| 844 | if (!actor) | 1241 | if (!actor) |
| 845 | return -EOPNOTSUPP; | 1242 | return -EOPNOTSUPP; |
| @@ -880,7 +1277,7 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr, | |||
| 880 | return actor(dev, edata.data); | 1277 | return actor(dev, edata.data); |
| 881 | } | 1278 | } |
| 882 | 1279 | ||
| 883 | static int ethtool_flash_device(struct net_device *dev, char __user *useraddr) | 1280 | static noinline_for_stack int ethtool_flash_device(struct net_device *dev, char __user *useraddr) |
| 884 | { | 1281 | { |
| 885 | struct ethtool_flash efl; | 1282 | struct ethtool_flash efl; |
| 886 | 1283 | ||
| @@ -1113,6 +1510,15 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
| 1113 | case ETHTOOL_RESET: | 1510 | case ETHTOOL_RESET: |
| 1114 | rc = ethtool_reset(dev, useraddr); | 1511 | rc = ethtool_reset(dev, useraddr); |
| 1115 | break; | 1512 | break; |
| 1513 | case ETHTOOL_SRXNTUPLE: | ||
| 1514 | rc = ethtool_set_rx_ntuple(dev, useraddr); | ||
| 1515 | break; | ||
| 1516 | case ETHTOOL_GRXNTUPLE: | ||
| 1517 | rc = ethtool_get_rx_ntuple(dev, useraddr); | ||
| 1518 | break; | ||
| 1519 | case ETHTOOL_GSSET_INFO: | ||
| 1520 | rc = ethtool_get_sset_info(dev, useraddr); | ||
| 1521 | break; | ||
| 1116 | default: | 1522 | default: |
| 1117 | rc = -EOPNOTSUPP; | 1523 | rc = -EOPNOTSUPP; |
| 1118 | } | 1524 | } |
